Every second time when i’m creating HttpsURLConnection and than calling getInputStream() method I’m getting an instance of LocalCloseInputStream instead of ChunkedInputStream, which immediately returns end when I try to read from this stream. There are not exceptions, just an empty stream.
I’ve already tried to set keep.alive to false and connection to close. This doesn’t work.
There two issues look pretty similar, but unfortunately I haven’t found any solution:
http://groups.google.com/group/android-developers/browse_thread/thread/d42c95992ae4dbda
http://groups.google.com/group/twitter4j/browse_thread/thread/105342823f7e3c67
For earlier versions of Android you should be using the Apache HTTP client. It works a lot better.
What you are seeing could be caused by calling
#getInputStream()more than once – have you checked what the default state for caching is in your app (for cupcake the cache is on by default for HTTP URL connections, i.e. the second time the response may be served from the cache, which is not likely to return aChunkedInputStream).You can turn caching off by calling
#setUseCaches(false)on your connection before using it (or disable it for all future connections by calling#setDefaultUseCaches(false)