[#1100 ] Fix SPDY codec to work again in 4.x
This commit is contained in:
parent
b6038534cc
commit
6246825fda
@ -108,9 +108,9 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
*/
|
||||
public static final String HOST = ":host";
|
||||
/**
|
||||
* {@code ":getMethod"}
|
||||
* {@code ":method"}
|
||||
*/
|
||||
public static final String METHOD = ":getMethod";
|
||||
public static final String METHOD = ":method";
|
||||
/**
|
||||
* {@code ":path"}
|
||||
*/
|
||||
@ -120,9 +120,9 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
*/
|
||||
public static final String SCHEME = ":scheme";
|
||||
/**
|
||||
* {@code ":getStatus"}
|
||||
* {@code ":status"}
|
||||
*/
|
||||
public static final String STATUS = ":getStatus";
|
||||
public static final String STATUS = ":status";
|
||||
/**
|
||||
* {@code ":version"}
|
||||
*/
|
||||
@ -136,17 +136,17 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
*/
|
||||
public static final class Spdy2HttpNames {
|
||||
/**
|
||||
* {@code "getMethod"}
|
||||
* {@code "method"}
|
||||
*/
|
||||
public static final String METHOD = "getMethod";
|
||||
public static final String METHOD = "method";
|
||||
/**
|
||||
* {@code "scheme"}
|
||||
*/
|
||||
public static final String SCHEME = "scheme";
|
||||
/**
|
||||
* {@code "getStatus"}
|
||||
* {@code "status"}
|
||||
*/
|
||||
public static final String STATUS = "getStatus";
|
||||
public static final String STATUS = "status";
|
||||
/**
|
||||
* {@code "url"}
|
||||
*/
|
||||
@ -231,7 +231,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the HTTP getMethod header.
|
||||
* Removes the HTTP method header.
|
||||
*/
|
||||
public static void removeMethod(int spdyVersion, SpdyHeaderBlock block) {
|
||||
if (spdyVersion < 3) {
|
||||
@ -242,7 +242,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link HttpMethod} represented by the HTTP getMethod header.
|
||||
* Returns the {@link HttpMethod} represented by the HTTP method header.
|
||||
*/
|
||||
public static HttpMethod getMethod(int spdyVersion, SpdyHeaderBlock block) {
|
||||
try {
|
||||
@ -257,7 +257,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP getMethod header.
|
||||
* Sets the HTTP method header.
|
||||
*/
|
||||
public static void setMethod(int spdyVersion, SpdyHeaderBlock block, HttpMethod method) {
|
||||
if (spdyVersion < 3) {
|
||||
@ -301,7 +301,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the HTTP response getStatus header.
|
||||
* Removes the HTTP response status header.
|
||||
*/
|
||||
public static void removeStatus(int spdyVersion, SpdyHeaderBlock block) {
|
||||
if (spdyVersion < 3) {
|
||||
@ -312,7 +312,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link HttpResponseStatus} represented by the HTTP response getStatus header.
|
||||
* Returns the {@link HttpResponseStatus} represented by the HTTP response status header.
|
||||
*/
|
||||
public static HttpResponseStatus getStatus(int spdyVersion, SpdyHeaderBlock block) {
|
||||
try {
|
||||
@ -341,7 +341,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP response getStatus header.
|
||||
* Sets the HTTP response status header.
|
||||
*/
|
||||
public static void setStatus(int spdyVersion, SpdyHeaderBlock block, HttpResponseStatus status) {
|
||||
if (spdyVersion < 3) {
|
||||
|
@ -142,11 +142,16 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
||||
protected Object encode(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
|
||||
List<Object> out = new ArrayList<Object>();
|
||||
|
||||
boolean valid = false;
|
||||
|
||||
if (msg instanceof HttpRequest) {
|
||||
|
||||
HttpRequest httpRequest = (HttpRequest) msg;
|
||||
SpdySynStreamFrame spdySynStreamFrame = createSynStreamFrame(httpRequest);
|
||||
out.add(spdySynStreamFrame);
|
||||
|
||||
valid = true;
|
||||
}
|
||||
if (msg instanceof HttpResponse) {
|
||||
|
||||
@ -158,6 +163,8 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
||||
SpdySynReplyFrame spdySynReplyFrame = createSynReplyFrame(httpResponse);
|
||||
out.add(spdySynReplyFrame);
|
||||
}
|
||||
|
||||
valid = true;
|
||||
}
|
||||
if (msg instanceof HttpContent) {
|
||||
|
||||
@ -185,7 +192,11 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
||||
} else {
|
||||
out.add(spdyDataFrame);
|
||||
}
|
||||
} else {
|
||||
|
||||
valid = true;
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw new UnsupportedMessageTypeException(msg);
|
||||
}
|
||||
|
||||
@ -255,8 +266,6 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
||||
|
||||
private SpdySynReplyFrame createSynReplyFrame(HttpResponse httpResponse)
|
||||
throws Exception {
|
||||
boolean chunked = HttpHeaders.isTransferEncodingChunked(httpResponse);
|
||||
|
||||
// Get the Stream-ID from the headers
|
||||
int streamID = SpdyHttpHeaders.getStreamId(httpResponse);
|
||||
SpdyHttpHeaders.removeStreamId(httpResponse);
|
||||
@ -279,10 +288,8 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<HttpObject> {
|
||||
spdySynReplyFrame.headers().add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (chunked) {
|
||||
currentStreamId = streamID;
|
||||
spdySynReplyFrame.setLast(false);
|
||||
}
|
||||
currentStreamId = streamID;
|
||||
spdySynReplyFrame.setLast(false);
|
||||
|
||||
return spdySynReplyFrame;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SpdySessionHandler
|
||||
|
||||
@Override
|
||||
public void freeInboundBuffer(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.inboundByteBuffer().release();
|
||||
ctx.inboundMessageBuffer().release();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user