Home / Function/ testGarbageHeaders() — netty Function Reference

testGarbageHeaders() — netty Function Reference

Architecture documentation for the testGarbageHeaders() function in HttpResponseDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  94fb66e5_1301_4db1_5e9a_1a8c1bee8d58["testGarbageHeaders()"]
  90546a8c_51c4_a9dc_b6e8_695d29269596["HttpResponseDecoderTest"]
  94fb66e5_1301_4db1_5e9a_1a8c1bee8d58 -->|defined in| 90546a8c_51c4_a9dc_b6e8_695d29269596
  style 94fb66e5_1301_4db1_5e9a_1a8c1bee8d58 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java lines 826–856

    @Test
    public void testGarbageHeaders() {
        // A response without headers - from https://github.com/netty/netty/issues/2103
        byte[] data = ("<html>\r\n" +
                "<head><title>400 Bad Request</title></head>\r\n" +
                "<body bgcolor=\"white\">\r\n" +
                "<center><h1>400 Bad Request</h1></center>\r\n" +
                "<hr><center>nginx/1.1.19</center>\r\n" +
                "</body>\r\n" +
                "</html>\r\n").getBytes();

        EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());

        ch.writeInbound(Unpooled.copiedBuffer(data));

        // Garbage input should generate the 999 Unknown response.
        HttpResponse res = ch.readInbound();
        assertSame(HttpVersion.HTTP_1_0, res.protocolVersion());
        assertEquals(999, res.status().code());
        assertTrue(res.decoderResult().isFailure());
        assertTrue(res.decoderResult().isFinished());
        assertNull(ch.readInbound());

        // More garbage should not generate anything (i.e. the decoder discards anything beyond this point.)
        ch.writeInbound(Unpooled.copiedBuffer(data));
        assertNull(ch.readInbound());

        // Closing the connection should not generate anything since the protocol has been violated.
        ch.finish();
        assertNull(ch.readInbound());
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free