@@ -191,4 +191,42 @@ public Future<ProxyResponse> handleProxyRequest(ProxyContext context) {
191191 });
192192 }));
193193 }
194+
195+ @ Test
196+ public void testWebSocketExtensionsNegotiatedBetweenClientAndBackend (TestContext ctx ) {
197+ Async async = ctx .async ();
198+ HttpServerOptions backendOptions = new HttpServerOptions ().setPort (8081 ).setHost ("localhost" )
199+ .setPerFrameWebSocketCompressionSupported (false ) // Disable extension in the backend
200+ .setPerMessageWebSocketCompressionSupported (false ); // Disable extension in the backend
201+ SocketAddress backend = startHttpBackend (ctx , backendOptions , req -> {
202+ ctx .assertTrue (req .headers ().contains ("sec-websocket-extensions" ));
203+ Future <ServerWebSocket > fut = req .toWebSocket ();
204+ fut .onComplete (ctx .asyncAssertSuccess (ws -> {
205+ ws .handler (buff -> ws .writeTextMessage (buff .toString ()));
206+ ws .closeHandler (v -> {
207+ async .complete ();
208+ });
209+ }));
210+ });
211+ startProxy (proxyServerOptions -> {
212+ return proxyServerOptions
213+ .setPerFrameWebSocketCompressionSupported (true ) // Enable extension in the proxy
214+ .setPerMessageWebSocketCompressionSupported (true ); // Enable extension in the proxy
215+ }, httpProxy -> httpProxy .origin (backend ));
216+ wsClient = vertx .createWebSocketClient (new WebSocketClientOptions ()
217+ .setTryUsePerFrameCompression (true ) // Enable extension in the client
218+ .setTryUsePerMessageCompression (true )); // Enable extension in the client
219+ WebSocketConnectOptions options = new WebSocketConnectOptions ()
220+ .setPort (8080 )
221+ .setHost ("localhost" )
222+ .setURI ("/ws" );
223+ wsClient .connect (options ).onComplete (ctx .asyncAssertSuccess (ws -> {
224+ ctx .assertFalse (ws .headers ().contains ("sec-websocket-extensions" ), "Expected extensions to be declined" );
225+ ws .textMessageHandler (msg -> {
226+ ctx .assertEquals ("hello" , msg );
227+ ws .close ();
228+ });
229+ ws .writeTextMessage ("hello" );
230+ }));
231+ }
194232}
0 commit comments