HTTPCLIENT-1605: EntityBuilder sets incorrect content length for entities backed by InputStream

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1655001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2015-01-27 10:35:08 +00:00
parent 306334fad7
commit 4a49a41a69
2 changed files with 2 additions and 1 deletions

View File

@ -317,7 +317,7 @@ public class EntityBuilder {
} else if (this.binary != null) {
e = new ByteArrayEntity(this.binary, getContentOrDefault(ContentType.DEFAULT_BINARY));
} else if (this.stream != null) {
e = new InputStreamEntity(this.stream, 1, getContentOrDefault(ContentType.DEFAULT_BINARY));
e = new InputStreamEntity(this.stream, -1, getContentOrDefault(ContentType.DEFAULT_BINARY));
} else if (this.parameters != null) {
e = new UrlEncodedFormEntity(this.parameters,
this.contentType != null ? this.contentType.getCharset() : null);

View File

@ -71,6 +71,7 @@ public class TestEntityBuilder {
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContent());
Assert.assertNotNull(entity.getContentType());
Assert.assertEquals(-1, entity.getContentLength());
Assert.assertEquals("application/octet-stream", entity.getContentType().getValue());
}