Skip to content

Commit b4256a6

Browse files
author
Tangshengbo
committed
Bug fixed: WebSocketServerCompressionHandler invalid
1 parent db29b04 commit b4256a6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.yeauty</groupId>
88
<artifactId>netty-websocket-spring-boot-starter</artifactId>
9-
<version>0.12.0</version>
9+
<version>0.12.1</version>
1010

1111
<name>netty-websocket-spring-boot-starter</name>
1212
<description>

src/main/java/org/yeauty/standard/HttpServerHandler.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,23 @@ private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
219219
subprotocols = ctx.channel().attr(subprotocolsAttrKey).get();
220220
}
221221
}
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+
}
223229
// Handshake
224230
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(getWebSocketLocation(req), subprotocols, true, config.getmaxFramePayloadLength());
225231
WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(req);
226232
if (handshaker == null) {
227233
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(channel);
228234
} else {
229-
ChannelPipeline pipeline = ctx.pipeline();
230235
pipeline.remove(ctx.name());
231236
if (config.getReaderIdleTimeSeconds() != 0 || config.getWriterIdleTimeSeconds() != 0 || config.getAllIdleTimeSeconds() != 0) {
232237
pipeline.addLast(new IdleStateHandler(config.getReaderIdleTimeSeconds(), config.getWriterIdleTimeSeconds(), config.getAllIdleTimeSeconds()));
233238
}
234-
if (config.isUseCompressionHandler()) {
235-
pipeline.addLast(new WebSocketServerCompressionHandler());
236-
}
237239
pipeline.addLast(new WebSocketFrameAggregator(Integer.MAX_VALUE));
238240
if (config.isUseEventExecutorGroup()) {
239241
pipeline.addLast(eventExecutorGroup, new WebSocketServerHandler(pojoEndpointServer));

0 commit comments

Comments
 (0)