Home / Function/ testRequestWithBodyAndTrailingHeaders() — netty Function Reference

testRequestWithBodyAndTrailingHeaders() — netty Function Reference

Architecture documentation for the testRequestWithBodyAndTrailingHeaders() function in HttpToHttp2ConnectionHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  548f687e_e3be_3678_f821_a2761bde0e43["testRequestWithBodyAndTrailingHeaders()"]
  919b1457_fbee_0bc0_c865_945a03b794b1["HttpToHttp2ConnectionHandlerTest"]
  548f687e_e3be_3678_f821_a2761bde0e43 -->|defined in| 919b1457_fbee_0bc0_c865_945a03b794b1
  5a522eb6_40fe_3d12_39a2_24e8e6f43e87["bootstrapEnv()"]
  548f687e_e3be_3678_f821_a2761bde0e43 -->|calls| 5a522eb6_40fe_3d12_39a2_24e8e6f43e87
  84d6c67b_74d9_4885_d2f1_6360667127ac["awaitRequests()"]
  548f687e_e3be_3678_f821_a2761bde0e43 -->|calls| 84d6c67b_74d9_4885_d2f1_6360667127ac
  style 548f687e_e3be_3678_f821_a2761bde0e43 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java lines 428–477

    @Test
    public void testRequestWithBodyAndTrailingHeaders() throws Exception {
        final String text = "foooooogoooo";
        final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<String>());
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock in) throws Throwable {
                receivedBuffers.add(((ByteBuf) in.getArguments()[2]).toString(UTF_8));
                return null;
            }
        }).when(serverListener).onDataRead(any(ChannelHandlerContext.class), eq(3),
                any(ByteBuf.class), eq(0), eq(false));
        bootstrapEnv(4, 1, 1);
        final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, POST,
                "http://your_user-name123@www.example.org:5555/example",
                Unpooled.copiedBuffer(text, UTF_8));
        final HttpHeaders httpHeaders = request.headers();
        httpHeaders.set(HttpHeaderNames.HOST, "www.example.org:5555");
        httpHeaders.add(of("foo"), of("goo"));
        httpHeaders.add(of("foo"), of("goo2"));
        httpHeaders.add(of("foo2"), of("goo2"));
        final Http2Headers http2Headers =
                new DefaultHttp2Headers().method(new AsciiString("POST")).path(new AsciiString("/example"))
                        .authority(new AsciiString("www.example.org:5555")).scheme(new AsciiString("http"))
                        .add(new AsciiString("foo"), new AsciiString("goo"))
                        .add(new AsciiString("foo"), new AsciiString("goo2"))
                        .add(new AsciiString("foo2"), new AsciiString("goo2"));

        request.trailingHeaders().add(of("trailing"), of("bar"));

        final Http2Headers http2TrailingHeaders = new DefaultHttp2Headers()
                .add(new AsciiString("trailing"), new AsciiString("bar"));

        ChannelPromise writePromise = newPromise();
        ChannelFuture writeFuture = clientChannel.writeAndFlush(request, writePromise);

        assertTrue(writePromise.awaitUninterruptibly(WAIT_TIME_SECONDS, SECONDS));
        assertTrue(writePromise.isSuccess());
        assertTrue(writeFuture.awaitUninterruptibly(WAIT_TIME_SECONDS, SECONDS));
        assertTrue(writeFuture.isSuccess());
        awaitRequests();
        verify(serverListener).onHeadersRead(any(ChannelHandlerContext.class), eq(3), eq(http2Headers), eq(0),
                anyShort(), anyBoolean(), eq(0), eq(false));
        verify(serverListener).onDataRead(any(ChannelHandlerContext.class), eq(3), any(ByteBuf.class), eq(0),
                eq(false));
        verify(serverListener).onHeadersRead(any(ChannelHandlerContext.class), eq(3), eq(http2TrailingHeaders), eq(0),
                anyShort(), anyBoolean(), eq(0), eq(true));
        assertEquals(1, receivedBuffers.size());
        assertEquals(text, receivedBuffers.get(0));
    }

Domain

Subdomains

Frequently Asked Questions

What does testRequestWithBodyAndTrailingHeaders() do?
testRequestWithBodyAndTrailingHeaders() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java.
Where is testRequestWithBodyAndTrailingHeaders() defined?
testRequestWithBodyAndTrailingHeaders() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java at line 428.
What does testRequestWithBodyAndTrailingHeaders() call?
testRequestWithBodyAndTrailingHeaders() calls 2 function(s): awaitRequests, bootstrapEnv.

Analyze Your Own Codebase

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

Try Supermodel Free