[#4185] SpdyHttpEncoder fails to convert HttpResponse to SpdyFrame
Motivation: When SpdyHttpEncoder attempts to create an SpdyHeadersFrame from a HttpResponse an IllegalArgumentException is thrown if the original HttpResponse contains a header that includes uppercase characters. The IllegalArgumentException is thrown due to the additional validation check introduced by #4047. Previous versions of the SPDY codec would handle this by converting the HTTP header name to lowercase before adding the header to the SpdyHeadersFrame. Modifications: Convert the header name to lowercase before adding it to SpdyHeaders Result: SpdyHttpEncoder can now convert a valid HttpResponse into a valid SpdyFrame
This commit is contained in:
parent
a26d2d7f16
commit
e751231fc5
@ -27,6 +27,7 @@ import io.netty.handler.codec.http.HttpObject;
|
|||||||
import io.netty.handler.codec.http.HttpRequest;
|
import io.netty.handler.codec.http.HttpRequest;
|
||||||
import io.netty.handler.codec.http.HttpResponse;
|
import io.netty.handler.codec.http.HttpResponse;
|
||||||
import io.netty.handler.codec.http.LastHttpContent;
|
import io.netty.handler.codec.http.LastHttpContent;
|
||||||
|
import io.netty.util.AsciiString;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -172,7 +173,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
|||||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(currentStreamId);
|
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(currentStreamId);
|
||||||
spdyHeadersFrame.setLast(true);
|
spdyHeadersFrame.setLast(true);
|
||||||
for (Map.Entry<CharSequence, CharSequence> entry: trailers) {
|
for (Map.Entry<CharSequence, CharSequence> entry: trailers) {
|
||||||
spdyHeadersFrame.headers().add(entry.getKey(), entry.getValue());
|
spdyHeadersFrame.headers().add(AsciiString.of(entry.getKey()).toLowerCase(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write DATA frame and append HEADERS frame
|
// Write DATA frame and append HEADERS frame
|
||||||
@ -233,7 +234,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
|||||||
|
|
||||||
// Transfer the remaining HTTP headers
|
// Transfer the remaining HTTP headers
|
||||||
for (Map.Entry<CharSequence, CharSequence> entry: httpHeaders) {
|
for (Map.Entry<CharSequence, CharSequence> entry: httpHeaders) {
|
||||||
frameHeaders.add(entry.getKey(), entry.getValue());
|
frameHeaders.add(AsciiString.of(entry.getKey()).toLowerCase(), entry.getValue());
|
||||||
}
|
}
|
||||||
currentStreamId = spdySynStreamFrame.streamId();
|
currentStreamId = spdySynStreamFrame.streamId();
|
||||||
if (associatedToStreamId == 0) {
|
if (associatedToStreamId == 0) {
|
||||||
@ -272,7 +273,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
|||||||
|
|
||||||
// Transfer the remaining HTTP headers
|
// Transfer the remaining HTTP headers
|
||||||
for (Map.Entry<CharSequence, CharSequence> entry: httpHeaders) {
|
for (Map.Entry<CharSequence, CharSequence> entry: httpHeaders) {
|
||||||
spdyHeadersFrame.headers().add(entry.getKey(), entry.getValue());
|
spdyHeadersFrame.headers().add(AsciiString.of(entry.getKey()).toLowerCase(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStreamId = streamId;
|
currentStreamId = streamId;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user