diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 58e7c311f..82bb45264 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -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 + * [HTTPCLIENT-1080] NTLM dead code commented out. Contributed by Karl Wright diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java index f4a0350bf..a78c5c6cb 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java @@ -155,8 +155,24 @@ public HttpResponse execute(HttpHost target, HttpRequest request, } 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); }