Some more tweaks

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@552278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2007-07-01 10:57:13 +00:00
parent 2563e6e1eb
commit 2dbe8c3557
1 changed files with 4 additions and 5 deletions

View File

@ -71,14 +71,12 @@ public class ClientConnectionRelease {
// If the response does not enclose an entity, there is no need
// to bother about connection release
if (entity != null) {
// do something useful with the response
BufferedReader reader = new BufferedReader(
new InputStreamReader(entity.getContent()));
try {
// do something useful with the response
System.out.println(reader.readLine());
// In case of an IOException the connection will be released
// back to the connection manager automatically
} catch (IOException ex) {
@ -99,7 +97,8 @@ public class ClientConnectionRelease {
// Closing the input stream will trigger connection release
reader.close();
// Alternatively you may want to call this method when done
// with the response entity. It will also trigger connection
// with the response entity to ensure the response content has
// been fully consumed. This will also trigger connection
// release
entity.consumeContent();