mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-04 15:49:12 +00:00
[OLINGO-405] Set content length for not chunked content
This commit is contained in:
parent
931f1324e6
commit
853bad6aa9
@ -366,11 +366,10 @@ public final class URIUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HttpEntity buildInputStreamEntity(final CommonODataClient<?> client, final InputStream input) {
|
public static HttpEntity buildInputStreamEntity(final CommonODataClient<?> client, final InputStream input) {
|
||||||
HttpEntity entity;
|
AbstractHttpEntity entity;
|
||||||
|
boolean useChunked = client.getConfiguration().isUseChuncked();
|
||||||
|
|
||||||
if (!shouldUseRepeatableHttpBodyEntry(client)) {
|
if (shouldUseRepeatableHttpBodyEntry(client) || !useChunked) {
|
||||||
entity = new InputStreamEntity(input, -1);
|
|
||||||
} else {
|
|
||||||
byte[] bytes = new byte[0];
|
byte[] bytes = new byte[0];
|
||||||
try {
|
try {
|
||||||
bytes = IOUtils.toByteArray(input);
|
bytes = IOUtils.toByteArray(input);
|
||||||
@ -380,10 +379,18 @@ public final class URIUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity = new ByteArrayEntity(bytes);
|
entity = new ByteArrayEntity(bytes);
|
||||||
|
} else {
|
||||||
|
entity = new InputStreamEntity(input, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!useChunked && entity.getContentLength() < 0) {
|
||||||
|
LOG.error("Could not determine length - request will be sent as chunked.");
|
||||||
|
useChunked = true;
|
||||||
|
}
|
||||||
// both entities can be sent in chunked way or not
|
// both entities can be sent in chunked way or not
|
||||||
((AbstractHttpEntity) entity).setChunked(client.getConfiguration().isUseChuncked());
|
entity.setChunked(useChunked);
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user