From 8224c95e059182292380d32f86e1c12961219111 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 29 Jun 2012 13:26:13 +0200 Subject: [PATCH] Port enhancement to reduce memory copy if possible. See #412 --- .../codec/http/HttpMessageDecoder.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java index f12a3f2647..409ed2e227 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java @@ -444,19 +444,40 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder= len) { + int index = internal.readerIndex(); + ByteBuf buf = internal.slice(index, len); + + // update the readerindex so an the next read its on the correct position + buffer.readerIndex(index + len); + return buf; + } else { + return buffer.readBytes(len); + } + } + private State readHeaders(ByteBuf buffer) throws TooLongFrameException { headerSize = 0; final HttpMessage message = this.message;