hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1787772 - /httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java
Date Mon, 20 Mar 2017 13:48:18 GMT
Author: olegk
Date: Mon Mar 20 13:48:18 2017
New Revision: 1787772

URL: http://svn.apache.org/viewvc?rev=1787772&view=rev
Log:
HTTPCLIENT-1832: Added content length parameter to InputStreamBody constructor

Modified:
    httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java

Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java?rev=1787772&r1=1787771&r2=1787772&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/InputStreamBody.java
Mon Mar 20 13:48:18 2017
@@ -45,6 +45,7 @@ public class InputStreamBody extends Abs
 
     private final InputStream in;
     private final String filename;
+    private final long contentLength;
 
     public InputStreamBody(final InputStream in, final String filename) {
         this(in, ContentType.DEFAULT_BINARY, filename);
@@ -54,10 +55,18 @@ public class InputStreamBody extends Abs
      * @since 4.3
      */
     public InputStreamBody(final InputStream in, final ContentType contentType, final String
filename) {
+        this(in, contentType, filename, -1);
+    }
+
+    /**
+     * @since 4.6
+     */
+    public InputStreamBody(final InputStream in, final ContentType contentType, final String
filename, final long contentLength) {
         super(contentType);
         Args.notNull(in, "Input stream");
         this.in = in;
         this.filename = filename;
+        this.contentLength = contentLength >= 0 ? contentLength : -1;
     }
 
     /**
@@ -93,7 +102,7 @@ public class InputStreamBody extends Abs
 
     @Override
     public long getContentLength() {
-        return -1;
+        return this.contentLength;
     }
 
     @Override



Mime
View raw message