From b5527e905ef3192db653dd3914aed4fda1ca8adb Mon Sep 17 00:00:00 2001 From: Jeff Pinner Date: Wed, 10 Jul 2013 12:20:46 -0700 Subject: [PATCH] fix SpdyHttpDecoder --- .../handler/codec/spdy/SpdyHttpDecoder.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java index f9a991916e..7041cfda79 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java @@ -108,7 +108,8 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { if (associatedToStreamId == 0) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.INVALID_STREAM); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); + return; } String URL = SpdyHeaders.getUrl(spdyVersion, spdySynStreamFrame); @@ -118,7 +119,8 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { if (URL == null) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.PROTOCOL_ERROR); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); + return; } // If a client receives a response with a truncated header block, @@ -126,7 +128,8 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { if (spdySynStreamFrame.isTruncated()) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.INTERNAL_ERROR); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); + return; } try { @@ -149,7 +152,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { } catch (Exception e) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.PROTOCOL_ERROR); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); } } else { // SYN_STREAM frames initiated by the client are HTTP requests @@ -163,7 +166,8 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { spdySynReplyFrame, HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE); SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, HttpVersion.HTTP_1_0); - out.add(spdySynReplyFrame); + ctx.writeAndFlush(spdySynReplyFrame); + return; } try { @@ -186,7 +190,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { spdySynReplyFrame.setLast(true); SpdyHeaders.setStatus(spdyVersion, spdySynReplyFrame, HttpResponseStatus.BAD_REQUEST); SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, HttpVersion.HTTP_1_0); - out.add(spdySynReplyFrame); + ctx.writeAndFlush(spdySynReplyFrame); } } @@ -200,7 +204,8 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { if (spdySynReplyFrame.isTruncated()) { SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.INTERNAL_ERROR); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); + return; } try { @@ -221,7 +226,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { // the client must reply with a RST_STREAM frame indicating a PROTOCOL_ERROR SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, SpdyStreamStatus.PROTOCOL_ERROR); - out.add(spdyRstStreamFrame); + ctx.writeAndFlush(spdyRstStreamFrame); } } else if (msg instanceof SpdyHeadersFrame) {