use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class WebSocketServerCompressionHandlerTest method testClientWindowSizeSuccess.
@Test
public void testClientWindowSizeSuccess() {
EmbeddedChannel ch = new EmbeddedChannel(new WebSocketServerExtensionHandler(new PerMessageDeflateServerExtensionHandshaker(6, false, 10, false, false)));
HttpRequest req = newUpgradeRequest(PERMESSAGE_DEFLATE_EXTENSION + "; " + CLIENT_MAX_WINDOW);
ch.writeInbound(req);
HttpResponse res = newUpgradeResponse(null);
ch.writeOutbound(res);
HttpResponse res2 = ch.readOutbound();
List<WebSocketExtensionData> exts = WebSocketExtensionUtil.extractExtensions(res2.headers().get(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
Assert.assertEquals(PERMESSAGE_DEFLATE_EXTENSION, exts.get(0).name());
Assert.assertEquals("10", exts.get(0).parameters().get(CLIENT_MAX_WINDOW));
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateDecoder.class) != null);
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateEncoder.class) != null);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class WebSocketServerCompressionHandlerTest method testNormalSuccess.
@Test
public void testNormalSuccess() {
EmbeddedChannel ch = new EmbeddedChannel(new WebSocketServerCompressionHandler());
HttpRequest req = newUpgradeRequest(PERMESSAGE_DEFLATE_EXTENSION);
ch.writeInbound(req);
HttpResponse res = newUpgradeResponse(null);
ch.writeOutbound(res);
HttpResponse res2 = ch.readOutbound();
List<WebSocketExtensionData> exts = WebSocketExtensionUtil.extractExtensions(res2.headers().get(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
Assert.assertEquals(PERMESSAGE_DEFLATE_EXTENSION, exts.get(0).name());
Assert.assertTrue(exts.get(0).parameters().isEmpty());
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateDecoder.class) != null);
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateEncoder.class) != null);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class DeflateFrameClientExtensionHandshakerTest method testNormalHandshake.
@Test
public void testNormalHandshake() {
DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(false);
WebSocketClientExtension extension = handshaker.handshakeExtension(new WebSocketExtensionData(DEFLATE_FRAME_EXTENSION, Collections.<String, String>emptyMap()));
assertNotNull(extension);
assertEquals(WebSocketClientExtension.RSV1, extension.rsv());
assertTrue(extension.newExtensionDecoder() instanceof PerFrameDeflateDecoder);
assertTrue(extension.newExtensionEncoder() instanceof PerFrameDeflateEncoder);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class DeflateFrameClientExtensionHandshakerTest method testWebkitDeflateFrameData.
@Test
public void testWebkitDeflateFrameData() {
DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(true);
WebSocketExtensionData data = handshaker.newRequestData();
assertEquals(X_WEBKIT_DEFLATE_FRAME_EXTENSION, data.name());
assertTrue(data.parameters().isEmpty());
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class DeflateFrameClientExtensionHandshakerTest method testDeflateFrameData.
@Test
public void testDeflateFrameData() {
DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(false);
WebSocketExtensionData data = handshaker.newRequestData();
assertEquals(DEFLATE_FRAME_EXTENSION, data.name());
assertTrue(data.parameters().isEmpty());
}
Aggregations