-
Bug
-
Resolution: Done
-
Major
-
7.0.0.CR2
-
None
-
None
Per HTTP spec, responses to HEAD requests should include Content-Length header indicating the entity size even though the entity itself is not included in response. Generic javax.servlet.http.HttpServlet.doHead() supports this as well.
However, RESTEasy skips the entity serialization for HEAD requests and thus returns the wrong Content-Length: 0. In org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse():
if (jaxrsResponse.getEntity() == null || request.getHttpMethod().equalsIgnoreCase("HEAD")) { response.setStatus(jaxrsResponse.getStatus()); commitHeaders(jaxrsResponse, response); return; }
Note this happens after the resource method already built the response, so all we're saving here is serialization – the heavy lifting of building the response already occurred.
- rfc2730 - Content-Length
A server MAY send a Content-Length header field in a response to a HEAD request (Section 4.3.2 of [RFC7231]); a server MUST NOT send Content-Length in such a response unless its field-value equals the decimal number of octets that would have been sent in the payload body of a response if the same request had used the GET method.
- rfc7231 - head
The HEAD method is identical to GET except that the server MUST NOT send a message body in the response (i.e., the response terminates at the end of the header section). The server SHOULD send the same header fields in response to a HEAD request as it would have sent if the request had been a GET, except that the payload header fields (Section 3.3) MAY be omitted.
- clones
-
RESTEASY-1365 HEAD requests always return Content-Length: 0
- Closed
- is cloned by
-
JBEAP-5447 (7.0.z) RESTEASY-1365 - HEAD requests always return Content-Length: 0
- Verified
- is incorporated by
-
JBEAP-5438 (7.1.0) Upgrade to RESTEasy 3.0.19.Final
- Verified