diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java index 2d8c25896d8..3072cd4215e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java @@ -41,6 +41,8 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest private final String path; + private byte[] data; + public NettyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest request) { this.request = request; this.params = new HashMap(); @@ -89,7 +91,10 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest } @Override public byte[] contentAsBytes() { - byte[] data = new byte[request.getContent().readableBytes()]; + if (this.data != null) { + return this.data; + } + data = new byte[request.getContent().readableBytes()]; request.getContent().getBytes(request.getContent().readerIndex(), data); return data; }