I\'m struggling with the following problem: My App makes sequence of requests to the http server using HttpClient. I use HttpPut for sending data to the server. First reques
Since many of these answers are old and depend upon the now depricated consumeContent()
method, I thought I'd answer with an alternative to the problem of Timeout waiting for connection from pool
.
HttpEntity someEntity = response.getEntity();
InputStream stream = someEntity.getContent();
BufferedReader rd = new BufferedReader(new InputStreamReader(stream));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
// On certain android OS levels / certain hardware, this is not enough.
stream.close(); // This line is what is recommended in the documentation
Here is what it shows in the documentation:
cz.msebera.android.httpclient.HttpEntity
@java.lang.Deprecated
public abstract void consumeContent()
throws java.io.IOException
This method is deprecated since version 4.1. Please use standard java
convention to ensure resource deallocation by calling
InputStream.close() on the input stream returned by getContent()