Home / Function/ writeLargeHeaders() — netty Function Reference

writeLargeHeaders() — netty Function Reference

Architecture documentation for the writeLargeHeaders() function in DefaultHttp2FrameWriterTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a01b360b_47db_8abd_b42e_e7cf09ddc891["writeLargeHeaders()"]
  602c48d7_d78b_d8f3_745e_26d2ab6ce0f2["DefaultHttp2FrameWriterTest"]
  a01b360b_47db_8abd_b42e_e7cf09ddc891 -->|defined in| 602c48d7_d78b_d8f3_745e_26d2ab6ce0f2
  18257f7e_6b98_6a1c_3968_7d340060c175["writeHeaders()"]
  a01b360b_47db_8abd_b42e_e7cf09ddc891 -->|calls| 18257f7e_6b98_6a1c_3968_7d340060c175
  a6ef6861_01af_480a_ff2a_92aba33e00e0["headerPayload()"]
  a01b360b_47db_8abd_b42e_e7cf09ddc891 -->|calls| a6ef6861_01af_480a_ff2a_92aba33e00e0
  style a01b360b_47db_8abd_b42e_e7cf09ddc891 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2FrameWriterTest.java lines 187–253

    @Test
    public void writeLargeHeaders() throws Exception {
        int streamId = 1;
        Http2Headers headers = new DefaultHttp2Headers()
                .method("GET").path("/").authority("foo.com").scheme("https");
        headers = dummyHeaders(headers, 60);

        http2HeadersEncoder.configuration().maxHeaderListSize(Integer.MAX_VALUE);
        frameWriter.headersConfiguration().maxHeaderListSize(Integer.MAX_VALUE);
        frameWriter.maxFrameSize(Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND);
        frameWriter.writeHeaders(ctx, streamId, headers, 0, true, promise);

        byte[] expectedPayload = headerPayload(streamId, headers);

        // First frame: HEADER(length=0x4000, type=0x01, flags=0x01)
        assertEquals(Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND,
                     outbound.readUnsignedMedium());
        assertEquals(0x01, outbound.readByte());
        assertEquals(0x01, outbound.readByte());
        assertEquals(streamId, outbound.readInt());

        byte[] firstPayload = new byte[Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND];
        outbound.readBytes(firstPayload);
        int index = 0;
        assertArrayEquals(Arrays.copyOfRange(expectedPayload, index, index + firstPayload.length),
                          firstPayload);
        index += firstPayload.length;

        // Second frame: HEADER(length=0x4000, type=0x09, flags=0x00)
        assertEquals(Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND,
                     outbound.readUnsignedMedium());
        assertEquals(0x09, outbound.readByte());
        assertEquals(0x00, outbound.readByte());
        assertEquals(streamId, outbound.readInt());

        byte[] secondPayload = new byte[Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND];
        outbound.readBytes(secondPayload);
        assertArrayEquals(Arrays.copyOfRange(expectedPayload, index, index + secondPayload.length),
                          secondPayload);
        index += secondPayload.length;

        // third frame: HEADER(length=0x4000, type=0x09, flags=0x00)
        assertEquals(Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND,
                     outbound.readUnsignedMedium());
        assertEquals(0x09, outbound.readByte());
        assertEquals(0x00, outbound.readByte());
        assertEquals(streamId, outbound.readInt());

        byte[] thirdPayload = new byte[Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND];
        outbound.readBytes(thirdPayload);
        assertArrayEquals(Arrays.copyOfRange(expectedPayload, index, index + thirdPayload.length),
                          thirdPayload);
        index += thirdPayload.length;

        int remainPayloadLength = expectedPayload.length - index;
        // Second frame: CONTINUATION(length=remainPayloadLength, type=0x09, flags=0x04)
        assertEquals(remainPayloadLength, outbound.readUnsignedMedium());
        assertEquals(0x09, outbound.readByte());
        assertEquals(0x04, outbound.readByte());
        assertEquals(streamId, outbound.readInt());

        byte[] fourthPayload = new byte[remainPayloadLength];
        outbound.readBytes(fourthPayload);

        assertArrayEquals(Arrays.copyOfRange(expectedPayload, index, index + fourthPayload.length),
                          fourthPayload);
    }

Domain

Subdomains

Frequently Asked Questions

What does writeLargeHeaders() do?
writeLargeHeaders() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2FrameWriterTest.java.
Where is writeLargeHeaders() defined?
writeLargeHeaders() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2FrameWriterTest.java at line 187.
What does writeLargeHeaders() call?
writeLargeHeaders() calls 2 function(s): headerPayload, writeHeaders.

Analyze Your Own Codebase

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

Try Supermodel Free