users@jersey.java.net

Re: Does Jersey set content-length header field automatically ?

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Tue, 16 Oct 2007 10:42:17 +0200

Hi James,

could you please file a RFE [1]?
I think that "Content-Length" header is not being
set automatically.

You can use [Response.Builder#header] method
to set the header manually on the server side.

Thanks,

~Jakub

[1]https://jersey.dev.java.net/issues/



On Tue, Oct 16, 2007 at 10:11:17AM +0200, James Weir wrote:
> Hi,
>
> Just created some client code using HttpURLConnection. I do the
> following check on the "content-length" header ....
>
> HttpURLConnection uc = null;
>
> ....// i do the request here
>
> if (uc.getContentLength()<=0) {
> logger.error("Reply from the the Web Service has " +
> uc.getContentLength() + " bytes");
> // Some sort of error has occurred
> super.setErrorCode(-1);
> super.setErrorMessage("Unable to get the user "+userName);
>
> // Depending upon the Http Response set the correct
> // response message
> super.setResponseMsg("User not found");
> return(null);
> }
>
> The server correctly returns JAXB information in the body, however it
> seems that the "content-length" header field is not set. Is this
> something I need to do explicitly when building the message on the
> server side ?. I was hoping that the REST API would set this for me, or
> am I being too lazy here :)
>
> Kind Regards
> James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>