spdyHeaderBlock.setInvalid();
return;
}
headerSize += nameLength;
if (headerSize > maxHeaderSize) {
throw new TooLongFrameException(
"Header block exceeds " + maxHeaderSize);
}
// Try to read name
if (!ensureBytes(nameLength)) {
decompressed.resetReaderIndex();
decompressed.discardReadBytes();
return;
}
byte[] nameBytes = new byte[nameLength];
decompressed.readBytes(nameBytes);
String name = new String(nameBytes, "UTF-8");
// Check for identically named headers
if (spdyHeaderBlock.containsHeader(name)) {
spdyHeaderBlock.setInvalid();
return;
}
// Try to read length of value
if (!ensureBytes(lengthFieldSize)) {
decompressed.resetReaderIndex();
decompressed.discardReadBytes();
return;
}
int valueLength = readLengthField();
// Recipients of illegal value fields must issue a stream error
if (valueLength < 0) {
spdyHeaderBlock.setInvalid();
return;
}
// SPDY/3 allows zero-length (empty) header values
if (valueLength == 0) {
if (version < 3) {
spdyHeaderBlock.setInvalid();
return;
} else {
spdyHeaderBlock.addHeader(name, "");
numHeaders --;
this.headerSize = headerSize;
continue;
}
}
headerSize += valueLength;
if (headerSize > maxHeaderSize) {
throw new TooLongFrameException(
"Header block exceeds " + maxHeaderSize);
}
// Try to read value
if (!ensureBytes(valueLength)) {