Jetty
  1. Jetty
  2. JETTY-1084

HEAD command not setting content-type in response under certain circumstances

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.18
    • Fix Version/s: 7.0.0, 6.1.21
    • Component/s: None
    • Labels:
      None
    • Environment:
      Running jetty-6.1.18 on CentOS 5.3 built with java 1.6u3
    • Number of attachments :
      5

      Description

      my UI developers have a jnlp file that downloads jars to run on the client. in Jetty 6.1.9 this worked for java 1.5 clients, but in 6.1.18, it does not work as expected. with java 1.5 clients, it complains that the Content-Type is null, and, it is:

      This is what the client sends to the server:

      mattrose@coltrane:~$ telnet 192.168.70.156 80
      Trying 192.168.70.156...
      Connected to 192.168.70.156.
      Escape character is '^]'.
      HEAD /webstart/N-central/jrcc-1.5.jar?version-id=7.0.0.888 HTTP/1.1
      pragma: no-cache
      accept-encoding: pack200-gzip,gzip
      Content-Type: application/x-java-archive; charset=utf-8
      User-Agent: JNLP/1.5 javaws/1.5.0_20 (b02) J2SE/1.5.0_20
      UA-Java-Version: 1.5.0_20
      Host: 192.168.101.108
      Accept: text/html, image/gif, image/jpeg, ; q=.2, */; q=.2
      Connection: keep-alive

      and this is the response from the server:

      HTTP/1.1 200 OK
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1403
      x-java-jnlp-version-id: 7.0.0.888
      Server: Jetty(6.1.9)

      But if I send the same thing to a 6.1.18 server, I get this in response:

      HTTP/1.1 200 OK
      x-java-jnlp-version-id: 7.0.0.892
      Content-Length: 0
      Server: Jetty(6.1.18)

      I tried to figure out why the difference exists, so that I could patch it myself, but I couldn't figure out why the Content-Type: header wasn't getting set in this one circumstance.

      1. Notepad.jnlp
        2 kB
        Matt Rose
      2. testcase.tar.gz
        88 kB
        Matt Rose
      3. web.xml
        9 kB
        Matt Rose

        Issue Links

          Activity

          Hide
          Matt Rose added a comment -

          web.xml I used

          Show
          Matt Rose added a comment - web.xml I used
          Hide
          Matt Rose added a comment -

          Oh, you're getting the 500 error because (I think) the jnlp-servlet.jar got corrupted somehow. I re-attached it, but any JDK from sun should also have it.

          HTH

          Show
          Matt Rose added a comment - Oh, you're getting the 500 error because (I think) the jnlp-servlet.jar got corrupted somehow. I re-attached it, but any JDK from sun should also have it. HTH
          Hide
          Athena Yao added a comment -

          Thanks for the updates!

          I've found the reason that the content-type isn't being sent – it is suppressed when a HEAD request would result in an error message (see http://fisheye.codehaus.org/changelog/jetty?cs=3472).

          It's masking the presence of an actual error message – a GET of /webstart/Notepad.jnlp (from the previous example/instructions) gives me the NPE I brought up earlier (and the HEAD has a null content type) ; a GET of /Notepad.jnlp works (and so does its HEAD).

          Show
          Athena Yao added a comment - Thanks for the updates! I've found the reason that the content-type isn't being sent – it is suppressed when a HEAD request would result in an error message (see http://fisheye.codehaus.org/changelog/jetty?cs=3472 ). It's masking the presence of an actual error message – a GET of /webstart/Notepad.jnlp (from the previous example/instructions) gives me the NPE I brought up earlier (and the HEAD has a null content type) ; a GET of /Notepad.jnlp works (and so does its HEAD).
          Hide
          Jan Bartel added a comment -

          Matt,

          I have changed jetty-6 trunk so that if an error is produced, you will get the full set of headers, rather than the truncated headers that would have been produced due to the changes to the error handling mentioned in Athena's previous comment.

          So the situation is now that that requests to the URL /Notepad.jnlp all work and produces HTTP 200 and a full set of headers.

          However, requests to /webstart/Notepad.jnlp produces an error, although with a full set of headers. The error message is reproduced below for your convenience, but I think it has nothing to do with jetty, but something to do with the configuration of the jnlp file itself:

          java.lang.NullPointerException
          	at jnlp.sample.servlet.JarDiffHandler.isJavawsVersion(JarDiffHandler.java:160)
          	at jnlp.sample.servlet.JnlpDownloadServlet.constructResponse(JnlpDownloadServlet.java:178)
          	at jnlp.sample.servlet.JnlpDownloadServlet.handleRequest(JnlpDownloadServlet.java:111)
          	at jnlp.sample.servlet.JnlpDownloadServlet.doGet(JnlpDownloadServlet.java:79)
          	at javax.servlet.http.HttpServlet.doHead(HttpServlet.java:281)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:724)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
          	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
          	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
          	at com.acme.TestFilter.doFilter(TestFilter.java:76)
          	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
          	at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:81)
          	at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:155)
          	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
          	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
          	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
          	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
          	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
          	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
          	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
          	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
          	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
          	at org.mortbay.jetty.Server.handle(Server.java:326)
          	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
          	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:913)
          	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
          	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
          	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
          	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
          	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
          

          cheers
          Jan

          Show
          Jan Bartel added a comment - Matt, I have changed jetty-6 trunk so that if an error is produced, you will get the full set of headers, rather than the truncated headers that would have been produced due to the changes to the error handling mentioned in Athena's previous comment. So the situation is now that that requests to the URL /Notepad.jnlp all work and produces HTTP 200 and a full set of headers. However, requests to /webstart/Notepad.jnlp produces an error, although with a full set of headers. The error message is reproduced below for your convenience, but I think it has nothing to do with jetty, but something to do with the configuration of the jnlp file itself: java.lang.NullPointerException at jnlp.sample.servlet.JarDiffHandler.isJavawsVersion(JarDiffHandler.java:160) at jnlp.sample.servlet.JnlpDownloadServlet.constructResponse(JnlpDownloadServlet.java:178) at jnlp.sample.servlet.JnlpDownloadServlet.handleRequest(JnlpDownloadServlet.java:111) at jnlp.sample.servlet.JnlpDownloadServlet.doGet(JnlpDownloadServlet.java:79) at javax.servlet.http.HttpServlet.doHead(HttpServlet.java:281) at javax.servlet.http.HttpServlet.service(HttpServlet.java:724) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at com.acme.TestFilter.doFilter(TestFilter.java:76) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:81) at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:155) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:913) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) cheers Jan
          Hide
          Jan Bartel added a comment -

          Fixed for jetty-6 head and jetty-7 head.

          Show
          Jan Bartel added a comment - Fixed for jetty-6 head and jetty-7 head.

            People

            • Assignee:
              Jan Bartel
              Reporter:
              Matt Rose
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: