mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-10 03:56:17 +00:00
HTTPCLIENT-1832: Added content length parameter to InputStreamBody constructor
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1787772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d07ee6fbc7
commit
db97c706d4
@ -45,6 +45,7 @@ public class InputStreamBody extends AbstractContentBody {
|
|||||||
|
|
||||||
private final InputStream in;
|
private final InputStream in;
|
||||||
private final String filename;
|
private final String filename;
|
||||||
|
private final long contentLength;
|
||||||
|
|
||||||
public InputStreamBody(final InputStream in, final String filename) {
|
public InputStreamBody(final InputStream in, final String filename) {
|
||||||
this(in, ContentType.DEFAULT_BINARY, filename);
|
this(in, ContentType.DEFAULT_BINARY, filename);
|
||||||
@ -54,10 +55,18 @@ public InputStreamBody(final InputStream in, final String filename) {
|
|||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public InputStreamBody(final InputStream in, final ContentType contentType, final String filename) {
|
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);
|
super(contentType);
|
||||||
Args.notNull(in, "Input stream");
|
Args.notNull(in, "Input stream");
|
||||||
this.in = in;
|
this.in = in;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
this.contentLength = contentLength >= 0 ? contentLength : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +102,7 @@ public String getTransferEncoding() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getContentLength() {
|
public long getContentLength() {
|
||||||
return -1;
|
return this.contentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user