mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-04 07:39:15 +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) {
|
||||
HttpEntity entity;
|
||||
AbstractHttpEntity entity;
|
||||
boolean useChunked = client.getConfiguration().isUseChuncked();
|
||||
|
||||
if (!shouldUseRepeatableHttpBodyEntry(client)) {
|
||||
entity = new InputStreamEntity(input, -1);
|
||||
} else {
|
||||
if (shouldUseRepeatableHttpBodyEntry(client) || !useChunked) {
|
||||
byte[] bytes = new byte[0];
|
||||
try {
|
||||
bytes = IOUtils.toByteArray(input);
|
||||
@ -380,10 +379,18 @@ public final class URIUtils {
|
||||
}
|
||||
|
||||
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
|
||||
((AbstractHttpEntity) entity).setChunked(client.getConfiguration().isUseChuncked());
|
||||
entity.setChunked(useChunked);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user