} else if (msg instanceof SpdyHeadersFrame) {
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
int streamId = spdyHeadersFrame.getStreamId();
HttpMessage httpMessage = getMessage(streamId);
// If message is not in map discard HEADERS frame.
if (httpMessage == null) {
return null;
}
// Ignore trailers in a truncated HEADERS frame.
if (!spdyHeadersFrame.isTruncated()) {
for (Map.Entry<String, String> e : spdyHeadersFrame.getHeaders()) {
httpMessage.addHeader(e.getKey(), e.getValue());
}
}
if (spdyHeadersFrame.isLast()) {
HttpHeaders.setContentLength(httpMessage, httpMessage.getContent().readableBytes());
removeMessage(streamId);
return httpMessage;
}
} else if (msg instanceof SpdyDataFrame) {
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
int streamId = spdyDataFrame.getStreamId();
HttpMessage httpMessage = getMessage(streamId);
// If message is not in map discard Data Frame.
if (httpMessage == null) {
return null;
}
ChannelBuffer content = httpMessage.getContent();
if (content.readableBytes() > maxContentLength - spdyDataFrame.getData().readableBytes()) {
removeMessage(streamId);
throw new TooLongFrameException(
"HTTP content length exceeded " + maxContentLength + " bytes.");
}
if (content == ChannelBuffers.EMPTY_BUFFER) {
content = ChannelBuffers.dynamicBuffer(channel.getConfig().getBufferFactory());
content.writeBytes(spdyDataFrame.getData());
httpMessage.setContent(content);
} else {
content.writeBytes(spdyDataFrame.getData());
}
if (spdyDataFrame.isLast()) {