Search code examples
javaapache-commons-httpclient

How to avoid calling ChunkedInputStream.exhaustInputStream(this) in commons-httpclient


I have a scene to random access http resources by adding header "Range:bytes=a-", I know the a value for the http request but have no idea about the end boundary. So... http request send and a response stream returned. when I have read the information I need(haven't read over the stream), I must close the stream, then the problem appeared: the close call must read all the data in that stream and costs too much time.

So, I guess that there is a socket pool in httpclient, so client must read all the data to ensure next response stream correct.

So, for avoiding this problem, does keepalive disabled work? or any other way could make the effect?


Solution

  • There is no way by using commons-httpclient to avoid that. So I used HttpURLConnection instead.