diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java index 36a4248c0a..20a79a0474 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java @@ -65,6 +65,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { private final String websocketPath; private final String subprotocols; private final boolean allowExtensions; + private final int maxFramePayloadLength; public WebSocketServerProtocolHandler(String websocketPath) { this(websocketPath, null, false); @@ -75,9 +76,15 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { } public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions) { + this(websocketPath, subprotocols, allowExtensions, 65536); + } + + public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, + boolean allowExtensions, int maxFrameSize) { this.websocketPath = websocketPath; this.subprotocols = subprotocols; this.allowExtensions = allowExtensions; + this.maxFramePayloadLength = maxFrameSize; } @Override @@ -86,7 +93,8 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { if (cp.get(WebSocketServerProtocolHandshakeHandler.class) == null) { // Add the WebSocketHandshakeHandler before this one. ctx.pipeline().addBefore(ctx.name(), WebSocketServerProtocolHandshakeHandler.class.getName(), - new WebSocketServerProtocolHandshakeHandler(websocketPath, subprotocols, allowExtensions)); + new WebSocketServerProtocolHandshakeHandler(websocketPath, subprotocols, + allowExtensions, maxFramePayloadLength)); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java index 46346a45d4..e1d638a12a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java @@ -40,12 +40,14 @@ class WebSocketServerProtocolHandshakeHandler extends ChannelHandlerAdapter { private final String websocketPath; private final String subprotocols; private final boolean allowExtensions; + private final int maxFramePayloadSize; WebSocketServerProtocolHandshakeHandler(String websocketPath, String subprotocols, - boolean allowExtensions) { + boolean allowExtensions, int maxFrameSize) { this.websocketPath = websocketPath; this.subprotocols = subprotocols; this.allowExtensions = allowExtensions; + this.maxFramePayloadSize = maxFrameSize; } @Override @@ -58,7 +60,8 @@ class WebSocketServerProtocolHandshakeHandler extends ChannelHandlerAdapter { } final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory( - getWebSocketLocation(ctx.pipeline(), req, websocketPath), subprotocols, allowExtensions); + getWebSocketLocation(ctx.pipeline(), req, websocketPath), subprotocols, + allowExtensions, maxFramePayloadSize); final WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(req); if (handshaker == null) { WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());