Home / Function/ testResponseChunkedWithValidUncommonPatterns() — netty Function Reference

testResponseChunkedWithValidUncommonPatterns() — netty Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java lines 179–249

    @Test
    public void testResponseChunkedWithValidUncommonPatterns() {
        EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
        ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n",
                                              CharsetUtil.US_ASCII));

        HttpResponse res = ch.readInbound();
        assertSame(HttpVersion.HTTP_1_1, res.protocolVersion());
        assertEquals(HttpResponseStatus.OK, res.status());

        byte[] data = new byte[1];
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) i;
        }

        // leading whitespace, trailing whitespace

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("  " + Integer.toHexString(data.length) + " \r\n",
                                                          CharsetUtil.US_ASCII)));
        assertTrue(ch.writeInbound(Unpooled.copiedBuffer(data)));
        HttpContent content = ch.readInbound();
        assertEquals(data.length, content.content().readableBytes());

        byte[] decodedData = new byte[data.length];
        content.content().readBytes(decodedData);
        assertArrayEquals(data, decodedData);
        content.release();

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII)));

        // leading whitespace, trailing control char

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("  " + Integer.toHexString(data.length) + "\0\r\n",
                                                          CharsetUtil.US_ASCII)));
        assertTrue(ch.writeInbound(Unpooled.copiedBuffer(data)));
        content = ch.readInbound();
        assertEquals(data.length, content.content().readableBytes());

        decodedData = new byte[data.length];
        content.content().readBytes(decodedData);
        assertArrayEquals(data, decodedData);
        content.release();

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII)));

        // leading whitespace, trailing semicolon

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("  " + Integer.toHexString(data.length) + ";\r\n",
                                                          CharsetUtil.US_ASCII)));
        assertTrue(ch.writeInbound(Unpooled.copiedBuffer(data)));
        content = ch.readInbound();
        assertEquals(data.length, content.content().readableBytes());

        decodedData = new byte[data.length];
        content.content().readBytes(decodedData);
        assertArrayEquals(data, decodedData);
        content.release();

        assertFalse(ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII)));

        // Write the last chunk.
        ch.writeInbound(Unpooled.copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII));

        // Ensure the last chunk was decoded.
        LastHttpContent lastContent = ch.readInbound();
        assertFalse(lastContent.content().isReadable());
        lastContent.release();

        ch.finish();
        assertNull(ch.readInbound());
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free