testHandshakeForHttpRequestWithoutAggregator() — netty Function Reference
Architecture documentation for the testHandshakeForHttpRequestWithoutAggregator() function in WebSocketServerHandshakerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2d9a7b93_82f5_2f86_b59b_e9d9b313f68d["testHandshakeForHttpRequestWithoutAggregator()"] 4971cbc5_410e_2355_1704_f949800b95fc["WebSocketServerHandshakerTest"] 2d9a7b93_82f5_2f86_b59b_e9d9b313f68d -->|defined in| 4971cbc5_410e_2355_1704_f949800b95fc style 2d9a7b93_82f5_2f86_b59b_e9d9b313f68d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerTest.java lines 124–179
@Test
public void testHandshakeForHttpRequestWithoutAggregator() {
EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder(), new HttpResponseEncoder());
WebSocketServerHandshaker serverHandshaker = newHandshaker("ws://example.com/chat",
"chat", WebSocketDecoderConfig.DEFAULT);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/chat");
request.headers()
.set(HttpHeaderNames.HOST, "example.com")
.set(HttpHeaderNames.ORIGIN, "example.com")
.set(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET)
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE)
.set(HttpHeaderNames.SEC_WEBSOCKET_KEY, "dGhlIHNhbXBsZSBub25jZQ==")
.set(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN, "http://example.com")
.set(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, "chat, superchat")
.set(HttpHeaderNames.SEC_WEBSOCKET_KEY1, "4 @1 46546xW%0l 1 5")
.set(HttpHeaderNames.SEC_WEBSOCKET_KEY2, "12998 5 Y3 1 .P00")
.set(HttpHeaderNames.WEBSOCKET_PROTOCOL, "chat, superchat")
.set(HttpHeaderNames.SEC_WEBSOCKET_VERSION, webSocketVersion().toAsciiString());
ChannelFuture future = serverHandshaker.handshake(channel, request);
assertFalse(future.isDone());
assertNotNull(channel.pipeline().get("handshaker"));
if (webSocketVersion() != WebSocketVersion.V00) {
assertNull(channel.pipeline().get("httpAggregator"));
channel.writeInbound(LastHttpContent.EMPTY_LAST_CONTENT);
} else {
assertNotNull(channel.pipeline().get("httpAggregator"));
channel.writeInbound(new DefaultLastHttpContent(
Unpooled.copiedBuffer("^n:ds[4U", CharsetUtil.US_ASCII)));
}
assertTrue(future.isDone());
assertNull(channel.pipeline().get("handshaker"));
ByteBuf byteBuf = channel.readOutbound();
assertFalse(channel.finish());
channel = new EmbeddedChannel(new HttpResponseDecoder());
assertTrue(channel.writeInbound(byteBuf));
HttpResponse response = channel.readInbound();
assertEquals(SWITCHING_PROTOCOLS, response.status());
assertTrue(response.headers().containsValue(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET, true));
LastHttpContent lastHttpContent = channel.readInbound();
if (webSocketVersion() != WebSocketVersion.V00) {
assertEquals(LastHttpContent.EMPTY_LAST_CONTENT, lastHttpContent);
} else {
assertEquals("8jKS'y:G*Co,Wxa-", lastHttpContent.content().toString(CharsetUtil.US_ASCII));
assertTrue(lastHttpContent.release());
}
assertFalse(channel.finish());
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does testHandshakeForHttpRequestWithoutAggregator() do?
testHandshakeForHttpRequestWithoutAggregator() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerTest.java.
Where is testHandshakeForHttpRequestWithoutAggregator() defined?
testHandshakeForHttpRequestWithoutAggregator() is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerTest.java at line 124.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free