@@ -84,32 +84,29 @@ public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exce
84
84
85
85
StreamedResponsePublisher publisher = (StreamedResponsePublisher ) attribute ;
86
86
87
- if (msg instanceof LastHttpContent ) {
88
- // Remove the handler from the pipeline, this will trigger
89
- // it to finish
90
- ctx .pipeline ().remove (publisher );
91
- // Trigger a read, just in case the last read complete
92
- // triggered no new read
93
- ctx .read ();
94
- // Send the last content on to the protocol, so that it can
95
- // conclude the cleanup
96
- protocol .handle (channel , publisher .future (), msg );
97
-
98
- } else if (msg instanceof HttpContent ) {
87
+ if (msg instanceof HttpContent ) {
99
88
ByteBuf content = ((HttpContent ) msg ).content ();
100
-
101
89
// Republish as a HttpResponseBodyPart
102
90
if (content .readableBytes () > 0 ) {
103
91
NettyResponseBodyPart part = config .getResponseBodyPartFactory ().newResponseBodyPart (content , false );
104
92
ctx .fireChannelRead (part );
105
93
}
106
-
94
+ if (msg instanceof LastHttpContent ) {
95
+ // Remove the handler from the pipeline, this will trigger
96
+ // it to finish
97
+ ctx .pipeline ().remove (publisher );
98
+ // Trigger a read, just in case the last read complete
99
+ // triggered no new read
100
+ ctx .read ();
101
+ // Send the last content on to the protocol, so that it can
102
+ // conclude the cleanup
103
+ protocol .handle (channel , publisher .future (), msg );
104
+ }
107
105
} else {
108
106
LOGGER .info ("Received unexpected message while expecting a chunk: " + msg );
109
107
ctx .pipeline ().remove ((StreamedResponsePublisher ) attribute );
110
108
Channels .setDiscard (channel );
111
109
}
112
-
113
110
} else if (attribute != DiscardEvent .INSTANCE ) {
114
111
// unhandled message
115
112
LOGGER .debug ("Orphan channel {} with attribute {} received message {}, closing" , channel , attribute , msg );
0 commit comments