From 9872b4977dedb1d81b140dfa95538d611d4f76c2 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 8 May 2010 03:34:31 +0300 Subject: [PATCH] cache data stored in http --- .../org/elasticsearch/http/netty/NettyHttpRequest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; }