Home / Function/ testEarlyBailout() — netty Function Reference

testEarlyBailout() — netty Function Reference

Architecture documentation for the testEarlyBailout() function in HttpClientUpgradeHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  3edc383e_4c37_2222_2b44_19e8186d8608["testEarlyBailout()"]
  64e7cef3_ca61_31ce_7834_0d1da2dc4960["HttpClientUpgradeHandlerTest"]
  3edc383e_4c37_2222_2b44_19e8186d8608 -->|defined in| 64e7cef3_ca61_31ce_7834_0d1da2dc4960
  style 3edc383e_4c37_2222_2b44_19e8186d8608 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java lines 167–197

    @Test
    public void testEarlyBailout() {
        HttpClientUpgradeHandler.SourceCodec sourceCodec = new FakeSourceCodec();
        HttpClientUpgradeHandler.UpgradeCodec upgradeCodec = new FakeUpgradeCodec();
        HttpClientUpgradeHandler handler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 1024);
        UserEventCatcher catcher = new UserEventCatcher();
        EmbeddedChannel channel = new EmbeddedChannel(catcher);
        channel.pipeline().addFirst("upgrade", handler);

        assertTrue(
            channel.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "netty.io")));
        FullHttpRequest request = channel.readOutbound();

        assertEquals(2, request.headers().size());
        assertTrue(request.headers().contains(HttpHeaderNames.UPGRADE, "fancyhttp", false));
        assertTrue(request.headers().contains("connection", "upgrade", false));
        assertTrue(request.release());
        assertEquals(HttpClientUpgradeHandler.UpgradeEvent.UPGRADE_ISSUED, catcher.getUserEvent());

        HttpResponse upgradeResponse =
            new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.SWITCHING_PROTOCOLS);
        upgradeResponse.headers().add(HttpHeaderNames.UPGRADE, "fancyhttp");
        assertTrue(channel.writeInbound(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)));

        assertEquals(HttpClientUpgradeHandler.UpgradeEvent.UPGRADE_REJECTED, catcher.getUserEvent());
        assertNull(channel.pipeline().get("upgrade"));

        HttpResponse response = channel.readInbound();
        assertEquals(HttpResponseStatus.OK, response.status());
        assertFalse(channel.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does testEarlyBailout() do?
testEarlyBailout() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java.
Where is testEarlyBailout() defined?
testEarlyBailout() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java at line 167.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free