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 E76D2174FC for ; Wed, 21 Oct 2015 08:49:10 +0000 (UTC) Received: (qmail 86009 invoked by uid 500); 21 Oct 2015 08:49:10 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 85971 invoked by uid 500); 21 Oct 2015 08:49:10 -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 85958 invoked by uid 99); 21 Oct 2015 08:49:10 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2015 08:49:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 6DC5C180992 for ; Wed, 21 Oct 2015 08:49:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.99 X-Spam-Level: X-Spam-Status: No, score=0.99 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 67oFYXiG23OW for ; Wed, 21 Oct 2015 08:49:09 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 0B3D020633 for ; Wed, 21 Oct 2015 08:49:09 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B1679E0454 for ; Wed, 21 Oct 2015 08:49:08 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id B11683A0337 for ; Wed, 21 Oct 2015 08:49:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1709763 - /httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java Date: Wed, 21 Oct 2015 08:49:08 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151021084908.B11683A0337@svn01-us-west.apache.org> Author: olegk Date: Wed Oct 21 08:49:08 2015 New Revision: 1709763 URL: http://svn.apache.org/viewvc?rev=1709763&view=rev Log: BufferedHttpEntity to use HttpEntity#writeTo when buffering non-repeatable entities Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java?rev=1709763&r1=1709762&r2=1709763&view=diff ============================================================================== --- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java (original) +++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java Wed Oct 21 08:49:08 2015 @@ -28,6 +28,7 @@ package org.apache.http.entity; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -35,7 +36,6 @@ import java.io.OutputStream; import org.apache.http.HttpEntity; import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; -import org.apache.http.util.EntityUtils; /** * A wrapping entity that buffers it content if necessary. @@ -60,7 +60,10 @@ public class BufferedHttpEntity extends public BufferedHttpEntity(final HttpEntity entity) throws IOException { super(entity); if (!entity.isRepeatable() || entity.getContentLength() < 0) { - this.buffer = EntityUtils.toByteArray(entity); + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + entity.writeTo(out); + out.flush(); + this.buffer = out.toByteArray(); } else { this.buffer = null; }