Minor performance optimization: do not consume content of an intermediate response if the underlying connection is not re-usable
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1511652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4db8167981
commit
78295c169a
|
@ -271,10 +271,8 @@ public class MainClientExec implements ClientExecChain {
|
|||
targetAuthState, proxyAuthState, route, request, response, context)) {
|
||||
// Make sure the response body is fully consumed, if present
|
||||
final HttpEntity entity = response.getEntity();
|
||||
EntityUtils.consume(entity);
|
||||
if (connHolder.isReusable()) {
|
||||
// TODO consume response body on if connection is re-usable
|
||||
// (requires post 4.3-beta2 bug fix in HttpCore)
|
||||
EntityUtils.consume(entity);
|
||||
} else {
|
||||
managedConn.close();
|
||||
if (proxyAuthState.getState() == AuthProtocolState.SUCCESS
|
||||
|
|
|
@ -528,7 +528,6 @@ public class TestMainClientExec {
|
|||
final CloseableHttpResponse finalResponse = mainClientExec.execute(
|
||||
route, request, context, execAware);
|
||||
Mockito.verify(requestExecutor, Mockito.times(2)).execute(request, managedConn, context);
|
||||
Mockito.verify(instream1).close();
|
||||
Mockito.verify(managedConn).close();
|
||||
Mockito.verify(instream2, Mockito.never()).close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue