On Jan 21, 2010, at 10:13 AM, Felipe Gaścho wrote:
> in the TTP protocol, you have:
>
> "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."
>
> but if you call a HEAD method done with Jersey, the content-lenght
> always returns zero ...
>
> is it right ?
>
This is a tricky because often one does not know the length until one
obtains the serialized data.
Jersey will attempt to set the Content-Length (for HEAD and GET) if
the length is known without any pre-computation (e.g. byte[], or
File). Otherwise it lets the HTTP container decide if chunked transfer
encoding should be used or not.
For the case when the length is not known in advance Jersey does not
set the Content-Length header to 0 for a HEAD response. Thus the HTTP
container is doing so and IMHO is incorrect and it should not be
adding such a header.
Since this is a "SHOULD" i think there is some wiggle room related to
Content-Length and transfer encoding.
Paul.