Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A6AE3D1BF for ; Wed, 12 Dec 2012 10:41:49 +0000 (UTC) Received: (qmail 38850 invoked by uid 500); 12 Dec 2012 10:41:49 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 38778 invoked by uid 500); 12 Dec 2012 10:41:47 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 38733 invoked by uid 99); 12 Dec 2012 10:41:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2012 10:41:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2012 10:41:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 059E6238896F for ; Wed, 12 Dec 2012 10:41:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1420613 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java Date: Wed, 12 Dec 2012 10:41:22 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121212104123.059E6238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Wed Dec 12 10:41:20 2012 New Revision: 1420613 URL: http://svn.apache.org/viewvc?rev=1420613&view=rev Log: 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 Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1420613&r1=1420612&r2=1420613&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original) +++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Wed Dec 12 10:41:20 2012 @@ -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 Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java?rev=1420613&r1=1420612&r2=1420613&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java Wed Dec 12 10:41:20 2012 @@ -155,8 +155,24 @@ public class DecompressingHttpClient imp } 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); }