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 ECCB917D34 for ; Wed, 21 Oct 2015 12:34:19 +0000 (UTC) Received: (qmail 64880 invoked by uid 500); 21 Oct 2015 12:34:19 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 64840 invoked by uid 500); 21 Oct 2015 12:34:19 -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 64831 invoked by uid 99); 21 Oct 2015 12:34:19 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2015 12:34:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4158A1A299E for ; Wed, 21 Oct 2015 12:34:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.991 X-Spam-Level: X-Spam-Status: No, score=0.991 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id fOo5Vvl_MM_i for ; Wed, 21 Oct 2015 12:34:15 +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 146EF20633 for ; Wed, 21 Oct 2015 12:34:15 +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 C062FE0454 for ; Wed, 21 Oct 2015 12:34:14 +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 BBA663A0337 for ; Wed, 21 Oct 2015 12:34:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1709814 - /httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java Date: Wed, 21 Oct 2015 12:34:14 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151021123414.BBA663A0337@svn01-us-west.apache.org> Author: olegk Date: Wed Oct 21 12:34:14 2015 New Revision: 1709814 URL: http://svn.apache.org/viewvc?rev=1709814&view=rev Log: MultipartFormEntity#getContent implementation Contributed by Slikey Modified: httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java Modified: httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java?rev=1709814&r1=1709813&r2=1709814&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java (original) +++ httpcomponents/httpclient/branches/4.5.x/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java Wed Oct 21 12:34:14 2015 @@ -27,16 +27,19 @@ package org.apache.http.entity.mime; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.http.ContentTooLongException; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicHeader; import org.apache.http.protocol.HTTP; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - @SuppressWarnings("deprecation") class MultipartFormEntity implements HttpEntity { @@ -94,8 +97,15 @@ class MultipartFormEntity implements Htt @Override public InputStream getContent() throws IOException { - throw new UnsupportedOperationException( - "Multipart form entity does not implement #getContent()"); + if (this.contentLength < 0) { + throw new ContentTooLongException("Content length is unknown"); + } else if (this.contentLength > 25 * 1024) { + throw new ContentTooLongException("Content length is too long: " + this.contentLength); + } + final ByteArrayOutputStream outstream = new ByteArrayOutputStream(); + writeTo(outstream); + outstream.flush(); + return new ByteArrayInputStream(outstream.toByteArray()); } @Override