There is an ajax js function which send request & get response and it often get successful but i smell somthing messy when i checked using firbug. please take a look.
when request success: ajaxRequest.getResponseHeader('content-Length'); returns null
But in actual the content-length is in digits. following is the firbug console output
HeadersResponseXML
Server Apache-Coyote/1.1
Content-Type text/xml
Transfer-Encoding chunked
Date Thu, 15 Sep 2011 07:23:36 GMT
when request failed : it returns 0 (zero),and it’s correct.
Headers
Server Apache-Coyote/1.1
Content-Length 0
Date Thu, 15 Sep 2011 07:23:53 GMT
I don’t see any content-length in response header when it succeed why? please compare success & failure firebug console output. How can I get actual content-length.
Read the javadoc of the
doGet()(ordoPost()) method ofHttpServlet:In other words, if you do not set the content length yourself inside your servlet and the response body is larger than the default response buffer size (often 2KB, configureable in server settings), then the servlet will send it using chunked encoding (technically, to prevent memory problems if it had to buffer large responses entirely in memory before being able to set the content length).
If you really need the content length in the response header for some reason, then you need to buffer the entire response body yourself before writing. E.g.
You only need to keep in mind that this can be a potential memory hog whenever the response body is extraordinary large.