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:
parent
2563e6e1eb
commit
2dbe8c3557
|
@ -71,14 +71,12 @@ public class ClientConnectionRelease {
|
||||||
// If the response does not enclose an entity, there is no need
|
// If the response does not enclose an entity, there is no need
|
||||||
// to bother about connection release
|
// to bother about connection release
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
// do something useful with the response
|
|
||||||
BufferedReader reader = new BufferedReader(
|
BufferedReader reader = new BufferedReader(
|
||||||
new InputStreamReader(entity.getContent()));
|
new InputStreamReader(entity.getContent()));
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// do something useful with the response
|
||||||
System.out.println(reader.readLine());
|
System.out.println(reader.readLine());
|
||||||
// In case of an IOException the connection will be released
|
|
||||||
// back to the connection manager automatically
|
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
||||||
|
@ -99,7 +97,8 @@ public class ClientConnectionRelease {
|
||||||
// Closing the input stream will trigger connection release
|
// Closing the input stream will trigger connection release
|
||||||
reader.close();
|
reader.close();
|
||||||
// Alternatively you may want to call this method when done
|
// 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
|
// release
|
||||||
entity.consumeContent();
|
entity.consumeContent();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue