You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Antonio Sargento (JIRA)" <ji...@apache.org> on 2013/07/30 12:25:53 UTC

[jira] [Created] (CXF-5167) HEAD operation implementation is not compliant with specification

Antonio Sargento created CXF-5167:
-------------------------------------

             Summary: HEAD operation implementation is not compliant with specification
                 Key: CXF-5167
                 URL: https://issues.apache.org/jira/browse/CXF-5167
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 2.7.5
            Reporter: Antonio Sargento


The implementation of HEAD operation is not compliant with the HTTP 1.1 specification.

{quote}
9.4 HEAD

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.
{quote}
Now, since the HEAD response doesn't have an body entity, the Content-lenght is equal to zero and the mime-type is set to text/plain.

I think that the problem is due the following code in class org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor (lines 228 - 236) 

{code}
// Write the entity
entity = InjectionUtils.getEntity(response.getEntity());
setResponseStatus(message, getActualStatus(response.getStatus(), entity));
if (entity == null) {
   responseHeaders.putSingle(HttpHeaders.CONTENT_LENGTH, "0");
   responseHeaders.remove(HttpHeaders.CONTENT_TYPE);
   message.remove(Message.CONTENT_TYPE);
   return;
}
{code}
 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira