} else if (msg instanceof SpdyHeadersFrame) {
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
int streamId = spdyHeadersFrame.streamId();
FullHttpMessage fullHttpMessage = getMessage(streamId);
// If message is not in map discard HEADERS frame.
if (fullHttpMessage == null) {
return;
}
// Ignore trailers in a truncated HEADERS frame.
if (!spdyHeadersFrame.isTruncated()) {
for (Map.Entry<String, String> e: spdyHeadersFrame.headers()) {
fullHttpMessage.headers().add(e.getKey(), e.getValue());
}
}
if (spdyHeadersFrame.isLast()) {
HttpHeaders.setContentLength(fullHttpMessage, fullHttpMessage.content().readableBytes());
removeMessage(streamId);
out.add(fullHttpMessage);
}
} else if (msg instanceof SpdyDataFrame) {
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
int streamId = spdyDataFrame.streamId();
FullHttpMessage fullHttpMessage = getMessage(streamId);
// If message is not in map discard Data Frame.
if (fullHttpMessage == null) {
return;
}
ByteBuf content = fullHttpMessage.content();
if (content.readableBytes() > maxContentLength - spdyDataFrame.content().readableBytes()) {
removeMessage(streamId);
throw new TooLongFrameException(
"HTTP content length exceeded " + maxContentLength + " bytes.");
}