Home / Function/ skippedUpgrade() — netty Function Reference

skippedUpgrade() — netty Function Reference

Architecture documentation for the skippedUpgrade() function in HttpServerUpgradeHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  daa470a4_a88a_73e1_62fa_34817a90580b["skippedUpgrade()"]
  b1c607f7_af7c_9e8d_7626_d168a967f7a0["HttpServerUpgradeHandlerTest"]
  daa470a4_a88a_73e1_62fa_34817a90580b -->|defined in| b1c607f7_af7c_9e8d_7626_d168a967f7a0
  style daa470a4_a88a_73e1_62fa_34817a90580b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpServerUpgradeHandlerTest.java lines 146–188

    @Test
    public void skippedUpgrade() {
        final HttpServerCodec httpServerCodec = new HttpServerCodec();
        final UpgradeCodecFactory factory = new UpgradeCodecFactory() {
            @Override
            public UpgradeCodec newUpgradeCodec(CharSequence protocol) {
                fail("Should never be invoked");
                return null;
            }
        };

        HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(httpServerCodec, factory) {
            @Override
            protected boolean shouldHandleUpgradeRequest(HttpRequest req) {
                return !req.headers().contains(HttpHeaderNames.UPGRADE, "do-not-upgrade", false);
            }
        };

        EmbeddedChannel channel = new EmbeddedChannel(httpServerCodec, upgradeHandler);

        String upgradeString = "GET / HTTP/1.1\r\n" +
                               "Host: example.com\r\n" +
                               "Connection: Upgrade\r\n" +
                               "Upgrade: do-not-upgrade\r\n\r\n";
        ByteBuf upgrade = Unpooled.copiedBuffer(upgradeString, CharsetUtil.US_ASCII);

        // The upgrade request should not be passed to the next handler without any processing.
        assertTrue(channel.writeInbound(upgrade));
        assertNotNull(channel.pipeline().get(HttpServerCodec.class));
        assertNull(channel.pipeline().get("marker"));

        HttpRequest req = channel.readInbound();
        assertThat(req).isNotInstanceOf(FullHttpRequest.class); // Should not be aggregated.
        assertTrue(req.headers().contains(HttpHeaderNames.CONNECTION, "Upgrade", false));
        assertTrue(req.headers().contains(HttpHeaderNames.UPGRADE, "do-not-upgrade", false));
        assertTrue(channel.readInbound() instanceof LastHttpContent);
        assertNull(channel.readInbound());

        // No response should be written because we're just passing through.
        channel.flushOutbound();
        assertNull(channel.readOutbound());
        assertFalse(channel.finishAndReleaseAll());
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free