Home / Function/ testResponseContentLength2() — netty Function Reference

testResponseContentLength2() — netty Function Reference

Architecture documentation for the testResponseContentLength2() function in HttpContentDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  79cd7439_1d87_3d80_43a4_e1ab890fcad2["testResponseContentLength2()"]
  ea4ec426_b689_ab52_a554_7959aed6c709["HttpContentDecoderTest"]
  79cd7439_1d87_3d80_43a4_e1ab890fcad2 -->|defined in| ea4ec426_b689_ab52_a554_7959aed6c709
  e1fd631d_8d14_d190_2463_40108ec003a4["assertHasInboundMessages()"]
  79cd7439_1d87_3d80_43a4_e1ab890fcad2 -->|calls| e1fd631d_8d14_d190_2463_40108ec003a4
  465668ef_fec3_d4d9_164f_24dc020645ba["assertHasOutboundMessages()"]
  79cd7439_1d87_3d80_43a4_e1ab890fcad2 -->|calls| 465668ef_fec3_d4d9_164f_24dc020645ba
  style 79cd7439_1d87_3d80_43a4_e1ab890fcad2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java lines 603–631

    @Test
    public void testResponseContentLength2() {
        // case 2: if HttpObjectAggregator is down the chain, then correct Content-Length header must be set

        // force content to be in more than one chunk (5 bytes/chunk)
        HttpResponseDecoder decoder = new HttpResponseDecoder(4096, 4096, 5);
        HttpContentDecoder decompressor = new HttpContentDecompressor(0);
        HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
        EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor, aggregator);
        String headers = "HTTP/1.1 200 OK\r\n" +
                         "Content-Length: " + GZ_HELLO_WORLD.length + "\r\n" +
                         "Content-Encoding: gzip\r\n" +
                         "\r\n";
        ByteBuf buf = Unpooled.copiedBuffer(headers.getBytes(CharsetUtil.US_ASCII), GZ_HELLO_WORLD);
        assertTrue(channel.writeInbound(buf));

        Object o = channel.readInbound();
        assertInstanceOf(FullHttpResponse.class, o);
        FullHttpResponse r = (FullHttpResponse) o;
        String v = r.headers().get(HttpHeaderNames.CONTENT_LENGTH);
        Long value = v == null ? null : Long.parseLong(v);
        assertNotNull(value);
        assertEquals(HELLO_WORLD.length(), value.longValue());
        r.release();

        assertHasInboundMessages(channel, false);
        assertHasOutboundMessages(channel, false);
        assertFalse(channel.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does testResponseContentLength2() do?
testResponseContentLength2() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java.
Where is testResponseContentLength2() defined?
testResponseContentLength2() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java at line 603.
What does testResponseContentLength2() call?
testResponseContentLength2() calls 2 function(s): assertHasInboundMessages, assertHasOutboundMessages.

Analyze Your Own Codebase

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

Try Supermodel Free