Question

I have a client who is posting some data to our server with http POST method. Our server is resin 3.0 with java. When I send response whether data is saved or not the the content length of the response is not set. client is using curl library(php wrapper over it) and they are receiving content length as 0. When I try to submit a form through a browser to our server on the same url it works and response is shown.

I tried using Apache HttpClient to submit data through postmethod and I received content length as -1 but i did get the full response. I'm not able to understand where is the problem. Also I did some google and found that resin do some chunked encoding while sending the response. But i guess it does this also for GET method. But for GET method my client is getting the content length and is able to get the response as well. Need help with this.

Was it helpful?

Solution

"Content-Length" is a header in the response, which warns the client on how big the response will be. It is not the actual length of the stream.

You can set it's value with response.setContentLength(...); in your Servlet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top