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 c04c950f76..8debd1c1bc 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 @@ -66,6 +66,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); @@ -76,9 +77,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 @@ -87,7 +94,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 a1f0d3e207..ac0cff7d49 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 @@ -41,12 +41,14 @@ class WebSocketServerProtocolHandshakeHandler 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 @@ -59,7 +61,8 @@ class WebSocketServerProtocolHandshakeHandler } 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());