views:

72

answers:

2

Using HttpClient 4.0, Im having an issue where the response I get from the ResponseHandler is only about half of what the actual page content should be (~61k bytes in the string vs ~125k in the page returned to a browser). I cant seem to find any place where there might be some sort of limit that would limit this. Any ideas?

Update: One other thing I have found is that the size returned by the entity's getContentLength method is -1, whereas it is a normal value for the previous request. The javadoc seems to indicate that means the length is unknown- Any ideas why that might be the case?

+1  A: 

This might not be it, but sometimes this can happen if you aren't flushing a stream somewhere.

Chris
Agreed. Especially if System.exit() is called when Threads are involved with the I/O.
nicerobot
This might be it-can you elaborate? The `DefaultHttpClient` that fetches that page also fetches 6+ before. Do I need to be explicitly flushing/clearing something?
Jackson Davis
I think you just need to be sure not to exit while there is still data left to read. Have a look at the javadoc http://goo.gl/iJjd with respect to closing the stream and javadoc for InputStream.available() http://goo.gl/qXUf
nicerobot
A: 

The other place you should look is on the server side.

One possibility is that the webapp code is occasionally throwing a wobbly halfway through writing the response. Another is that there's a bug in the server container code. For instance, I vaguely recall that there was a bug in some older versions of Tomcat that caused large responses to be mangled / truncated.

Stephen C