diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java index 56cbbe0265927..d5cf31d54fe82 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java @@ -127,6 +127,12 @@ public HttpRequest releaseAndCopy() { } try { final ByteBuf copiedContent = Unpooled.copiedBuffer(request.content()); + HttpBody newContent; + if (content.isStream()) { + newContent = content; + } else { + newContent = Netty4Utils.fullHttpBodyFrom(copiedContent); + } return new Netty4HttpRequest( sequence, new DefaultFullHttpRequest( @@ -139,7 +145,7 @@ public HttpRequest releaseAndCopy() { ), new AtomicBoolean(false), false, - content + newContent ); } finally { release();