Skip to content

Commit b72a94e

Browse files
committed
Merge pull request #394 from johanhaleby/0.4.x
SSE now works with preceding channel handlers such as SSL
2 parents 901ca86 + 52b44a8 commit b72a94e

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

rxnetty/src/main/java/io/reactivex/netty/protocol/http/sse/SSEInboundHandler.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,7 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg)
7474
ctx.channel().attr(ClientRequestResponseConverter.DISCARD_CONNECTION).set(true); // SSE traffic should always discard connection on close.
7575

7676
ChannelPipeline pipeline = ctx.channel().pipeline();
77-
if (!HttpHeaders.isTransferEncodingChunked((HttpResponse) msg)) {
78-
pipeline.addFirst(SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
79-
/*
80-
* If there are buffered messages in the previous handler at the time this message is read, we would
81-
* not be able to convert the content into an SseEvent. For this reason, we also add the decoder after
82-
* this handler, so that we can handle the buffered messages.
83-
* See the class level javadoc for more details.
84-
*/
85-
pipeline.addAfter(NAME, SSE_DECODER_POST_INBOUND_HANDLER, new ServerSentEventDecoder());
86-
} else {
87-
pipeline.addAfter(NAME, SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
88-
}
77+
pipeline.addAfter(NAME, SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
8978
ctx.fireChannelRead(msg);
9079
} else if (msg instanceof LastHttpContent) {
9180
LastHttpContent lastHttpContent = (LastHttpContent) msg;

rxnetty/src/main/java/io/reactivex/netty/protocol/http/sse/SseChannelHandler.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,7 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg)
6969
ctx.channel().attr(ClientRequestResponseConverter.DISCARD_CONNECTION).set(true); // SSE traffic should always discard connection on close.
7070

7171
ChannelPipeline pipeline = ctx.channel().pipeline();
72-
if (!HttpHeaders.isTransferEncodingChunked((HttpResponse) msg)) {
73-
pipeline.addFirst(SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
74-
/*
75-
* If there are buffered messages in the previous handler at the time this message is read, we would
76-
* not be able to convert the content into an SseEvent. For this reason, we also add the decoder after
77-
* this handler, so that we can handle the buffered messages.
78-
* See the class level javadoc for more details.
79-
*/
80-
pipeline.addAfter(NAME, SSE_DECODER_POST_INBOUND_HANDLER, new ServerSentEventDecoder());
81-
} else {
82-
pipeline.addAfter(NAME, SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
83-
}
72+
pipeline.addAfter(NAME, SSE_DECODER_HANDLER_NAME, new ServerSentEventDecoder());
8473
ctx.fireChannelRead(msg);
8574
} else if (msg instanceof LastHttpContent) {
8675
LastHttpContent lastHttpContent = (LastHttpContent) msg;

0 commit comments

Comments
 (0)