diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java index d0c1ae2dd9a..ef39b3394d2 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java @@ -28,6 +28,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.Extension; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; @@ -245,6 +246,17 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames this.nextOutgoing = nextOutgoing; } + public void setPolicy(WebSocketPolicy policy) + { + for (Extension extension : extensions) + { + if (extension instanceof AbstractExtension) + { + ((AbstractExtension)extension).setPolicy(policy); + } + } + } + @Override public String toString() { @@ -283,4 +295,3 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames return s.toString(); } } - diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java index 1ca3ef7b21f..cc4095eac77 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java @@ -533,6 +533,7 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc WebSocketServerConnection wsConnection = new WebSocketServerConnection(endp,executor,scheduler,driver.getPolicy(),bufferPool,this); connection = wsConnection; + extensionStack.setPolicy(driver.getPolicy()); extensionStack.configure(wsConnection.getParser()); extensionStack.configure(wsConnection.getGenerator()); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java index 66e23525831..57fb8de0593 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java @@ -38,5 +38,9 @@ public class EchoServlet extends WebSocketServlet // Setup the desired Socket to use for all incoming upgrade requests factory.register(EchoSocket.class); + + // Some alternate sizes + factory.getPolicy().setMaxBinaryMessageSize(2222); + factory.getPolicy().setMaxTextMessageSize(4444); } }