Port the changes in SpdyHeaderBlockRawDecoder to master & 4.0
Somehow it slipped away.
This commit is contained in:
parent
b8de47484a
commit
febc53daaa
@ -21,34 +21,27 @@ import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder {
|
||||
|
||||
private static final int LENGTH_FIELD_SIZE = 4;
|
||||
|
||||
private final int version;
|
||||
private final int maxHeaderSize;
|
||||
private final int lengthFieldSize;
|
||||
|
||||
// Header block decoding fields
|
||||
private int headerSize;
|
||||
private int numHeaders;
|
||||
private int numHeaders = -1;
|
||||
|
||||
public SpdyHeaderBlockRawDecoder(SpdyVersion version, int maxHeaderSize) {
|
||||
if (version == null) {
|
||||
throw new NullPointerException("version");
|
||||
public SpdyHeaderBlockRawDecoder(SpdyVersion spdyVersion, int maxHeaderSize) {
|
||||
if (spdyVersion == null) {
|
||||
throw new NullPointerException("spdyVersion");
|
||||
}
|
||||
|
||||
this.version = version.getVersion();
|
||||
version = spdyVersion.getVersion();
|
||||
this.maxHeaderSize = maxHeaderSize;
|
||||
lengthFieldSize = this.version < 3 ? 2 : 4;
|
||||
reset();
|
||||
}
|
||||
|
||||
private int readLengthField(ByteBuf buffer) {
|
||||
int length;
|
||||
if (version < 3) {
|
||||
length = getUnsignedShort(buffer, buffer.readerIndex());
|
||||
buffer.skipBytes(2);
|
||||
} else {
|
||||
length = getSignedInt(buffer, buffer.readerIndex());
|
||||
buffer.skipBytes(4);
|
||||
}
|
||||
private static int readLengthField(ByteBuf buffer) {
|
||||
int length = getSignedInt(buffer, buffer.readerIndex());
|
||||
buffer.skipBytes(LENGTH_FIELD_SIZE);
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -63,7 +56,7 @@ public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder {
|
||||
|
||||
if (numHeaders == -1) {
|
||||
// Read number of Name/Value pairs
|
||||
if (encoded.readableBytes() < lengthFieldSize) {
|
||||
if (encoded.readableBytes() < LENGTH_FIELD_SIZE) {
|
||||
return;
|
||||
}
|
||||
numHeaders = readLengthField(encoded);
|
||||
@ -78,7 +71,7 @@ public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder {
|
||||
encoded.markReaderIndex();
|
||||
|
||||
// Try to read length of name
|
||||
if (encoded.readableBytes() < lengthFieldSize) {
|
||||
if (encoded.readableBytes() < LENGTH_FIELD_SIZE) {
|
||||
encoded.resetReaderIndex();
|
||||
return;
|
||||
}
|
||||
@ -111,7 +104,7 @@ public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder {
|
||||
}
|
||||
|
||||
// Try to read length of value
|
||||
if (encoded.readableBytes() < lengthFieldSize) {
|
||||
if (encoded.readableBytes() < LENGTH_FIELD_SIZE) {
|
||||
encoded.resetReaderIndex();
|
||||
return;
|
||||
}
|
||||
@ -125,15 +118,10 @@ public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder {
|
||||
|
||||
// SPDY/3 allows zero-length (empty) header values
|
||||
if (valueLength == 0) {
|
||||
if (version < 3) {
|
||||
frame.setInvalid();
|
||||
return;
|
||||
} else {
|
||||
frame.headers().add(name, "");
|
||||
numHeaders --;
|
||||
this.headerSize = headerSize;
|
||||
continue;
|
||||
}
|
||||
frame.headers().add(name, "");
|
||||
numHeaders --;
|
||||
this.headerSize = headerSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
headerSize += valueLength;
|
||||
|
Loading…
Reference in New Issue
Block a user