cache data stored in http

This commit is contained in:
kimchy 2010-05-08 03:34:31 +03:00
parent 473b46f5ef
commit 9872b4977d
1 changed files with 6 additions and 1 deletions

View File

@ -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<String, String>();
@ -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;
}