SPDY: SpdyFrameDecoder should buffer unread data when decoding headers

This commit is contained in:
Jeff Pinner 2013-06-28 00:40:01 -07:00 committed by Trustin Lee
parent 5f1aa6afde
commit 1b40a0ebc5

View File

@ -230,10 +230,10 @@ public class SpdyFrameDecoder extends ByteToMessageDecoder {
case READ_HEADER_BLOCK:
int compressedBytes = Math.min(buffer.readableBytes(), length);
length -= compressedBytes;
ByteBuf compressed = buffer.slice(buffer.readerIndex(), compressedBytes);
try {
headerBlockDecoder.decode(buffer.readSlice(compressedBytes), spdyHeadersFrame);
headerBlockDecoder.decode(compressed, spdyHeadersFrame);
} catch (Exception e) {
state = State.FRAME_ERROR;
spdyHeadersFrame = null;
@ -241,6 +241,10 @@ public class SpdyFrameDecoder extends ByteToMessageDecoder {
return;
}
int readBytes = compressedBytes - compressed.readableBytes();
buffer.skipBytes(readBytes);
length -= readBytes;
if (spdyHeadersFrame != null &&
(spdyHeadersFrame.isInvalid() || spdyHeadersFrame.isTruncated())) {