HTTPCLIENT-1273: DecompressingHttpClient does not automatically consume response content in case of an i/o, HTTP or runtime exception thrown by the decompressing protocol interceptor leading to a potential connection leak

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1420613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-12-12 10:41:20 +00:00
parent 278e06df47
commit 6425e97a02
2 changed files with 23 additions and 2 deletions

View File

@ -1,6 +1,11 @@
Changes in trunk
-------------------
* [HTTPCLIENT-1273] DecompressingHttpClient does not automatically consume response
content in case of an i/o, HTTP or runtime exception thrown by the decompressing
protocol interceptor leading to a potential connection leak.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-1080] NTLM dead code commented out.
Contributed by Karl Wright <DaddyWri at gmail.com>

View File

@ -155,8 +155,24 @@ public class DecompressingHttpClient implements HttpClient {
}
acceptEncodingInterceptor.process(wrapped, context);
HttpResponse response = backend.execute(target, wrapped, context);
contentEncodingInterceptor.process(response, context);
return response;
try {
contentEncodingInterceptor.process(response, context);
if (Boolean.TRUE.equals(context.getAttribute(ResponseContentEncoding.UNCOMPRESSED))) {
response.removeHeaders("Content-Length");
response.removeHeaders("Content-Encoding");
response.removeHeaders("Content-MD5");
}
return response;
} catch (HttpException ex) {
EntityUtils.consume(response.getEntity());
throw ex;
} catch (IOException ex) {
EntityUtils.consume(response.getEntity());
throw ex;
} catch (RuntimeException ex) {
EntityUtils.consume(response.getEntity());
throw ex;
}
} catch (HttpException e) {
throw new ClientProtocolException(e);
}