Search in sources :

Example 11 with WebSocketExtensionData

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);
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpResponse(io.netty.handler.codec.http.HttpResponse) WebSocketServerExtensionHandler(io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler) PerMessageDeflateServerExtensionHandshaker(io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateServerExtensionHandshaker) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 12 with WebSocketExtensionData

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);
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpResponse(io.netty.handler.codec.http.HttpResponse) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 13 with WebSocketExtensionData

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);
}
Also used : WebSocketClientExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 14 with WebSocketExtensionData

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());
}
Also used : WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 15 with WebSocketExtensionData

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());
}
Also used : WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Aggregations

WebSocketExtensionData (io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData)19 Test (org.junit.Test)19 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)6 HttpRequest (io.netty.handler.codec.http.HttpRequest)6 HttpResponse (io.netty.handler.codec.http.HttpResponse)6 PerMessageDeflateServerExtensionHandshaker (io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateServerExtensionHandshaker)6 WebSocketServerExtension (io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtension)5 WebSocketClientExtension (io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension)4 WebSocketServerExtensionHandler (io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler)4 DeflateFrameServerExtensionHandshaker (io.netty.handler.codec.http.websocketx.extensions.compression.DeflateFrameServerExtensionHandshaker)3 HashMap (java.util.HashMap)1