readHeadersFrame() — netty Function Reference
Architecture documentation for the readHeadersFrame() function in DefaultHttp2FrameReader.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7359663e_1255_5053_ca98_1c1b54534bc2["readHeadersFrame()"] 3768d640_58c2_34e7_3d69_a4b578e0d11a["DefaultHttp2FrameReader"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|defined in| 3768d640_58c2_34e7_3d69_a4b578e0d11a e711693c_32ed_ac69_29f1_ce5694750979["processPayloadState()"] e711693c_32ed_ac69_29f1_ce5694750979 -->|calls| 7359663e_1255_5053_ca98_1c1b54534bc2 3b43af15_c215_93fc_5c51_a2abe4d047d9["readPadding()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| 3b43af15_c215_93fc_5c51_a2abe4d047d9 64b75707_7a6c_7e26_98ea_05793212d7e4["lengthWithoutTrailingPadding()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| 64b75707_7a6c_7e26_98ea_05793212d7e4 d810894b_be57_6864_4a7d_32bddb4d68f3["getStreamId()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| d810894b_be57_6864_4a7d_32bddb4d68f3 ca5e2820_c99c_1b79_5ed5_5304bbcba862["processFragment()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| ca5e2820_c99c_1b79_5ed5_5304bbcba862 d3cf3714_2259_6a41_c730_30d5c2dc9945["addFragment()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| d3cf3714_2259_6a41_c730_30d5c2dc9945 a643c6da_1c17_3da8_8399_b25cd9e26e55["resetHeadersContinuationIfEnd()"] 7359663e_1255_5053_ca98_1c1b54534bc2 -->|calls| a643c6da_1c17_3da8_8399_b25cd9e26e55 style 7359663e_1255_5053_ca98_1c1b54534bc2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2FrameReader.java lines 411–483
private void readHeadersFrame(final ChannelHandlerContext ctx, ByteBuf payload,
Http2FrameListener listener) throws Http2Exception {
final int headersStreamId = streamId;
final Http2Flags headersFlags = flags;
final int padding = readPadding(payload);
// The callback that is invoked is different depending on whether priority information
// is present in the headers frame.
if (flags.priorityPresent()) {
long word1 = payload.readUnsignedInt();
final boolean exclusive = (word1 & 0x80000000L) != 0;
final int streamDependency = (int) (word1 & 0x7FFFFFFFL);
if (streamDependency == streamId) {
// Stream dependencies are deprecated in RFC 9113 but this behavior is defined in
// https://datatracker.ietf.org/doc/html/rfc7540#section-5.3.1 which says this must be treated as a
// stream error of type PROTOCOL_ERROR. However, because we will not process the payload, a stream
// error would result in HPACK corruption. Therefor, it is elevated to a connection error.
throw connectionError(
PROTOCOL_ERROR, "HEADERS frame for stream %d cannot depend on itself.", streamId);
}
final short weight = (short) (payload.readUnsignedByte() + 1);
final int lenToRead = lengthWithoutTrailingPadding(payload.readableBytes(), padding);
// Create a handler that invokes the listener when the header block is complete.
headersContinuation = new HeadersContinuation() {
@Override
public int getStreamId() {
return headersStreamId;
}
@Override
public void processFragment(boolean endOfHeaders, ByteBuf fragment, int len,
Http2FrameListener listener) throws Http2Exception {
final HeadersBlockBuilder hdrBlockBuilder = headersBlockBuilder();
hdrBlockBuilder.addFragment(fragment, len, ctx.alloc(), endOfHeaders);
if (endOfHeaders) {
listener.onHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(), streamDependency,
weight, exclusive, padding, headersFlags.endOfStream());
}
}
};
// Process the initial fragment, invoking the listener's callback if end of headers.
headersContinuation.processFragment(flags.endOfHeaders(), payload, lenToRead, listener);
resetHeadersContinuationIfEnd(flags.endOfHeaders());
return;
}
// The priority fields are not present in the frame. Prepare a continuation that invokes
// the listener callback without priority information.
headersContinuation = new HeadersContinuation() {
@Override
public int getStreamId() {
return headersStreamId;
}
@Override
public void processFragment(boolean endOfHeaders, ByteBuf fragment, int len,
Http2FrameListener listener) throws Http2Exception {
final HeadersBlockBuilder hdrBlockBuilder = headersBlockBuilder();
hdrBlockBuilder.addFragment(fragment, len, ctx.alloc(), endOfHeaders);
if (endOfHeaders) {
listener.onHeadersRead(ctx, headersStreamId, hdrBlockBuilder.headers(), padding,
headersFlags.endOfStream());
}
}
};
// Process the initial fragment, invoking the listener's callback if end of headers.
int len = lengthWithoutTrailingPadding(payload.readableBytes(), padding);
headersContinuation.processFragment(flags.endOfHeaders(), payload, len, listener);
resetHeadersContinuationIfEnd(flags.endOfHeaders());
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does readHeadersFrame() do?
readHeadersFrame() is a function in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2FrameReader.java.
Where is readHeadersFrame() defined?
readHeadersFrame() is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2FrameReader.java at line 411.
What does readHeadersFrame() call?
readHeadersFrame() calls 6 function(s): addFragment, getStreamId, lengthWithoutTrailingPadding, processFragment, readPadding, resetHeadersContinuationIfEnd.
What calls readHeadersFrame()?
readHeadersFrame() is called by 1 function(s): processPayloadState.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free