Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-15150

Content is returned for HEAD requests when using gzip

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • core
    • Jenkins 1.458 and later. Reproduced on 1.466.1 and 1.481. The Jenkins instance is behind Apache using mod_proxy.

      The Jenkins connector for Mylyn issues a HEAD / request followed by a GET /api/xml request. When an "Accept-Encoding: gzip" header is included in the requests, Jenkins sends unexpected content as part of the response to the HEAD request which breaks the HTTP connection.

      This can be reproduced by running the Jenkins 1.481 and curl:

      $ curl -v --keepalive -H "Accept-Encoding: gzip,deflate" --head http://localhost:8080/? http://localhost:8080/?

      > HEAD /? HTTP/1.1
      ...
      < HTTP/1.1 200 OK
      < Set-Cookie: JSESSIONID.e8d41638=6c7970ab0aa9ccf39d999cdbe95f53d4; Path=/; <

      • Connection #0 to host localhost left intact
      • Connection #0 seems to be dead!
      • Closing connection #0
      • About to connect() to localhost port 8080 (#0)
      • Trying 127.0.0.1... connected
        > HEAD /? HTTP/1.1

      Instead of keeping the connection alive curl closes it because the response wasn't valid.

      This problem breaks the Jenkins connector for Mylyn: https://bugs.eclipse.org/bugs/show_bug.cgi?id=376468

          [JENKINS-15150] Content is returned for HEAD requests when using gzip

          anb0s added a comment -

          This issue blocks us to use latest Jenkins LTS 1.466.1 and Mylyn connector.

          anb0s added a comment - This issue blocks us to use latest Jenkins LTS 1.466.1 and Mylyn connector.

          The example below is maybe more clear than the description. This violates the HTTP spec that states that the "server MUST NOT return a message-body in the response" for HEAD requests: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4.

          $ nc localhost 8080
          HEAD /? HTTP/1.1
          Accept-Encoding: gzip,deflate

          HTTP/1.1 200 OK
          Server: Winstone Servlet Engine v0.9.10
          Content-Encoding: gzip
          Expires: 0
          Cache-Control: no-cache,must-revalidate
          X-Hudson-Theme: default
          Content-Type: text/html;charset=UTF-8
          X-Hudson: 1.395
          X-Jenkins: 1.481
          X-Jenkins-Session: 16e694bb
          X-Hudson-CLI-Port: 55248
          X-Jenkins-CLI-Port: 55248
          X-Jenkins-CLI2-Port: 55248
          X-SSH-Endpoint: 127.0.0.1:38694
          Content-Length: 3750
          Connection: Keep-Alive
          Date: Thu, 13 Sep 2012 06:09:02 GMT
          X-Powered-By: Servlet/2.5 (Winstone/0.9.10)
          Set-Cookie: JSESSIONID.e8d41638=2a67514147fe0022332ef37297bd0dfd; Path=/; HttpOnly

          �Z�r�H���B��]����6�
          ▒|oll���e����y��Y�'۬]`�v73#�Tʫ2�Y�ѯ���ۧ~[��cſ▒ǿH��
          ...

          The same happens when the Accept-Encoding header is not included. The difference is though that the server closes the connection (for whichever reason) so subsequent requests are likely to succeed. It would be better if the server kept the connection alive and returned a valid response.

          $ nc localhost 8080
          HEAD /? HTTP/1.1

          HTTP/1.1 200 OK
          Server: Winstone Servlet Engine v0.9.10
          Expires: 0
          Cache-Control: no-cache,must-revalidate
          X-Hudson-Theme: default
          Content-Type: text/html;charset=UTF-8
          X-Hudson: 1.395
          X-Jenkins: 1.481
          X-Jenkins-Session: 16e694bb
          X-Hudson-CLI-Port: 55248
          X-Jenkins-CLI-Port: 55248
          X-Jenkins-CLI2-Port: 55248
          X-SSH-Endpoint: 127.0.0.1:38694
          Connection: Close
          Date: Thu, 13 Sep 2012 06:11:13 GMT
          X-Powered-By: Servlet/2.5 (Winstone/0.9.10)
          Set-Cookie: JSESSIONID.e8d41638=d616b2e4bd984bb32e675c49e87662ff; Path=/; HttpOnly

          <!DOCTYPE html><html><head>
          ...

          Steffen Pingel added a comment - The example below is maybe more clear than the description. This violates the HTTP spec that states that the "server MUST NOT return a message-body in the response" for HEAD requests: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4 . $ nc localhost 8080 HEAD /? HTTP/1.1 Accept-Encoding: gzip,deflate HTTP/1.1 200 OK Server: Winstone Servlet Engine v0.9.10 Content-Encoding: gzip Expires: 0 Cache-Control: no-cache,must-revalidate X-Hudson-Theme: default Content-Type: text/html;charset=UTF-8 X-Hudson: 1.395 X-Jenkins: 1.481 X-Jenkins-Session: 16e694bb X-Hudson-CLI-Port: 55248 X-Jenkins-CLI-Port: 55248 X-Jenkins-CLI2-Port: 55248 X-SSH-Endpoint: 127.0.0.1:38694 Content-Length: 3750 Connection: Keep-Alive Date: Thu, 13 Sep 2012 06:09:02 GMT X-Powered-By: Servlet/2.5 (Winstone/0.9.10) Set-Cookie: JSESSIONID.e8d41638=2a67514147fe0022332ef37297bd0dfd; Path=/; HttpOnly �Z�r�H���B��]����6� ▒|oll�� �e����y��Y�'۬ ]`�v73#�Tʫ2�Y�ѯ���ۧ~[��cſ▒ǿH�� ... The same happens when the Accept-Encoding header is not included. The difference is though that the server closes the connection (for whichever reason) so subsequent requests are likely to succeed. It would be better if the server kept the connection alive and returned a valid response. $ nc localhost 8080 HEAD /? HTTP/1.1 HTTP/1.1 200 OK Server: Winstone Servlet Engine v0.9.10 Expires: 0 Cache-Control: no-cache,must-revalidate X-Hudson-Theme: default Content-Type: text/html;charset=UTF-8 X-Hudson: 1.395 X-Jenkins: 1.481 X-Jenkins-Session: 16e694bb X-Hudson-CLI-Port: 55248 X-Jenkins-CLI-Port: 55248 X-Jenkins-CLI2-Port: 55248 X-SSH-Endpoint: 127.0.0.1:38694 Connection: Close Date: Thu, 13 Sep 2012 06:11:13 GMT X-Powered-By: Servlet/2.5 (Winstone/0.9.10) Set-Cookie: JSESSIONID.e8d41638=d616b2e4bd984bb32e675c49e87662ff; Path=/; HttpOnly <!DOCTYPE html><html><head> ...

          The above comment shows that Jenkins is being run on Winstone. Is this the same for everyone else with this issue?

          Michael Clarke added a comment - The above comment shows that Jenkins is being run on Winstone. Is this the same for everyone else with this issue?

          Looks like this was also reported on JENKINS-13480.

          Steffen Pingel added a comment - Looks like this was also reported on JENKINS-13480 .

            mc1arke Michael Clarke
            spingel2 Steffen Pingel
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: