diff --git a/pom.xml b/pom.xml
index f0c186f06..eea952d5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,7 @@
${major.version}.${minor.version}
4
1
- 0
+ 1
4.1.0
diff --git a/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java b/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java
index 5996d2b9e..08e41f42c 100644
--- a/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java
+++ b/src/main/java/org/aksw/iguana/cc/utils/http/StreamEntityProducer.java
@@ -39,13 +39,11 @@ public class StreamEntityProducer implements AsyncEntityProducer {
* @param streamSupplier the input stream supplier, should be repeatable
* @param chunked whether the entity data should be sent in chunks
*/
- public StreamEntityProducer(Supplier streamSupplier, boolean chunked, String contentType) throws IOException {
+ public StreamEntityProducer(Supplier streamSupplier, boolean chunked, String contentType) {
this.streamSupplier = streamSupplier;
this.chunked = chunked;
this.contentType = contentType;
- if (!chunked) {
- content = (streamSupplier.get() instanceof ByteArrayListInputStream) ? (ByteArrayListInputStream) streamSupplier.get() : null;
- }
+ if (!chunked) loadContent();
}
@Override
@@ -132,7 +130,8 @@ public int available() {
@Override
public void produce(DataStreamChannel channel) throws IOException {
// handling of non-chunked request
- if (content != null) {
+ if (!chunked) {
+ if (content == null) loadContent(); // might be necessary if the producer is reused
ByteBuffer buffer = content.getCurrentBuffer();
while (channel.write(buffer) > 0) {
if (!buffer.hasRemaining()) {
@@ -148,7 +147,7 @@ public void produce(DataStreamChannel channel) throws IOException {
}
// handling of chunked request
- if (chunked && currentStream == null) {
+ if (currentStream == null) {
currentStream = streamSupplier.get();
}
@@ -162,4 +161,8 @@ public void produce(DataStreamChannel channel) throws IOException {
channel.endStream();
}
}
+
+ private void loadContent() {
+ content = (ByteArrayListInputStream) streamSupplier.get();
+ }
}
\ No newline at end of file