Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1424

HTTP/2 HEAD responses include a body

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.14.Final
    • 2.0.13.Final
    • Core
    • None
    • Hide

      Compile and run the attached file, HeadTest.java. It uses the java.net.http.HttpClient class that is in Java 11, not sure if that was in earlier Javas.

      Show
      Compile and run the attached file, HeadTest.java. It uses the java.net.http.HttpClient class that is in Java 11, not sure if that was in earlier Javas.

      HTTP/2 HEAD responses include a body.

      If HTTP/2 is enabled in the Undertow server and the client also supports HTTP/2, and the client makes a HEAD request, the response from the server will include a body. As I understand it, HEAD responses should not include a body. https://tools.ietf.org/html/rfc7231#section-4.3.2

      If HTTP/2 is not enabled on the server or the client does not support HTTP/2, then the responses to HEAD do not include bodies, which is the desired behavior.

      I notice in HttpServerConnection.getSinkConduit, it calls HttpTransferEncoding.createSinkConduit, and that second method has code related to HEAD requests:

      https://github.com/undertow-io/undertow/blob/f29cd1f3a16bfe6bfbc5a8d4cb2052ececc2063e/core/src/main/java/io/undertow/server/protocol/http/HttpServerConnection.java#L202-L210

      https://github.com/undertow-io/undertow/blob/f29cd1f3a16bfe6bfbc5a8d4cb2052ececc2063e/core/src/main/java/io/undertow/server/protocol/http/HttpTransferEncoding.java#L202-L250

      Meanwhile in Http2ServerConnection.getSinkConduit, there seems to be no HEAD-related code:

      https://github.com/undertow-io/undertow/blob/f29cd1f3a16bfe6bfbc5a8d4cb2052ececc2063e/core/src/main/java/io/undertow/server/protocol/http2/Http2ServerConnection.java#L325-L332

      Maybe that is the issue? That the code in Undertow that ensures HEAD responses are empty is in the HTTP 1.x code path but missing from the HTTP/2 code path?

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              mhixson1_jira Michael Hixson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: