@@ -219,21 +219,23 @@ private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
219
219
subprotocols = ctx .channel ().attr (subprotocolsAttrKey ).get ();
220
220
}
221
221
}
222
-
222
+ ChannelPipeline pipeline = ctx .pipeline ();
223
+ if (config .isUseCompressionHandler ()) {
224
+ // Add WebSocketServerCompressionHandler, but don't shake hands
225
+ pipeline .addLast (new WebSocketServerCompressionHandler ());
226
+ // Let the request by WebSocketServerCompressionHandler forwarding to the next handler
227
+ ctx .fireChannelRead (req .retain ());
228
+ }
223
229
// Handshake
224
230
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory (getWebSocketLocation (req ), subprotocols , true , config .getmaxFramePayloadLength ());
225
231
WebSocketServerHandshaker handshaker = wsFactory .newHandshaker (req );
226
232
if (handshaker == null ) {
227
233
WebSocketServerHandshakerFactory .sendUnsupportedVersionResponse (channel );
228
234
} else {
229
- ChannelPipeline pipeline = ctx .pipeline ();
230
235
pipeline .remove (ctx .name ());
231
236
if (config .getReaderIdleTimeSeconds () != 0 || config .getWriterIdleTimeSeconds () != 0 || config .getAllIdleTimeSeconds () != 0 ) {
232
237
pipeline .addLast (new IdleStateHandler (config .getReaderIdleTimeSeconds (), config .getWriterIdleTimeSeconds (), config .getAllIdleTimeSeconds ()));
233
238
}
234
- if (config .isUseCompressionHandler ()) {
235
- pipeline .addLast (new WebSocketServerCompressionHandler ());
236
- }
237
239
pipeline .addLast (new WebSocketFrameAggregator (Integer .MAX_VALUE ));
238
240
if (config .isUseEventExecutorGroup ()) {
239
241
pipeline .addLast (eventExecutorGroup , new WebSocketServerHandler (pojoEndpointServer ));
0 commit comments