Home / Class/ Http3HeadersSink Class — netty Architecture

Http3HeadersSink Class — netty Architecture

Architecture documentation for the Http3HeadersSink class in Http3HeadersSink.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4["Http3HeadersSink"]
  ce022ffc_e909_8242_feb1_fa02993174f3["Http3HeadersSink.java"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|defined in| ce022ffc_e909_8242_feb1_fa02993174f3
  8356f12a_007c_f306_1899_e428847400cb["Http3HeadersSink()"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|method| 8356f12a_007c_f306_1899_e428847400cb
  73e61a10_dc7f_b1aa_9db6_8a00480711c6["finish()"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|method| 73e61a10_dc7f_b1aa_9db6_8a00480711c6
  549ec78d_c464_7480_1160_dd309c3e68b7["authorityOrHostHeaderReceived()"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|method| 549ec78d_c464_7480_1160_dd309c3e68b7
  3e93004a_af2f_c154_00e3_da6f04fc3bc6["accept()"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|method| 3e93004a_af2f_c154_00e3_da6f04fc3bc6
  32d30781_9415_0458_7c5d_8612347eea84["validate()"]
  7f15a7d9_1c9f_da48_4b29_ed705f5855b4 -->|method| 32d30781_9415_0458_7c5d_8612347eea84

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/Http3HeadersSink.java lines 36–205

final class Http3HeadersSink implements BiConsumer<CharSequence, CharSequence> {
    private final Http3Headers headers;
    private final long maxHeaderListSize;
    private final boolean validate;
    private final boolean trailer;
    private long headersLength;
    private boolean exceededMaxLength;
    private Http3HeadersValidationException validationException;
    private HeaderType previousType;
    private boolean request;
    private int receivedPseudoHeaders;

    Http3HeadersSink(Http3Headers headers, long maxHeaderListSize, boolean validate, boolean trailer) {
        this.headers = headers;
        this.maxHeaderListSize = maxHeaderListSize;
        this.validate = validate;
        this.trailer = trailer;
    }

    /**
     * This method must be called after the sink is used.
     */
    void finish() throws Http3HeadersValidationException, Http3Exception {
        if (exceededMaxLength) {
            throw new Http3Exception(Http3ErrorCode.H3_EXCESSIVE_LOAD,
                    String.format("Header size exceeded max allowed size (%d)", maxHeaderListSize));
        }
        if (validationException != null) {
            throw validationException;
        }
        if (validate) {
            if (trailer) {
                if (receivedPseudoHeaders != 0) {
                    // Trailers must not have pseudo headers.
                    throw new Http3HeadersValidationException("Pseudo-header(s) included in trailers.");
                }
                return;
            }

            // Validate that all mandatory pseudo-headers are included.
            if (request) {
                CharSequence method = headers.method();
                // fast-path
                if (HttpMethod.CONNECT.asciiName().contentEqualsIgnoreCase(method)) {
                    // Check if this is an Extended CONNECT request (RFC 9220)
                    // Extended CONNECT includes the :protocol pseudo-header
                    if ((receivedPseudoHeaders & PROTOCOL.getFlag()) != 0) {
                        // Extended CONNECT (RFC 9220) requires:
                        // - :method
                        // - :scheme
                        // - :authority
                        // - :path
                        // - :protocol
                        final int requiredPseudoHeaders = METHOD.getFlag() | SCHEME.getFlag() |
                                                         AUTHORITY.getFlag() | PATH.getFlag() | PROTOCOL.getFlag();
                        if (receivedPseudoHeaders != requiredPseudoHeaders) {
                            throw new Http3HeadersValidationException(
                                    "Not all mandatory pseudo-headers included for Extended CONNECT.");
                        }
                    } else {
                        // Regular CONNECT (RFC 9114) requires:
                        // - :method
                        // - :authority
                        final int requiredPseudoHeaders = METHOD.getFlag() | AUTHORITY.getFlag();
                        if (receivedPseudoHeaders != requiredPseudoHeaders) {
                            throw new Http3HeadersValidationException("Not all mandatory pseudo-headers included.");
                        }
                    }
                } else if (HttpMethod.OPTIONS.asciiName().contentEqualsIgnoreCase(method)) {
                    // See:
                    //
                    // https://www.rfc-editor.org/rfc/rfc9114.html#section-4.3.1
                    // https://www.rfc-editor.org/rfc/rfc9110#section-7.1
                    // - :method
                    // - :scheme
                    // - :authority
                    // - :path
                    final int requiredPseudoHeaders = METHOD.getFlag() | SCHEME.getFlag() | PATH.getFlag();
                    if ((receivedPseudoHeaders & requiredPseudoHeaders) != requiredPseudoHeaders ||
                            (!authorityOrHostHeaderReceived() && !"*".contentEquals(headers.path()))) {
                        throw new Http3HeadersValidationException("Not all mandatory pseudo-headers included.");

Frequently Asked Questions

What is the Http3HeadersSink class?
Http3HeadersSink is a class in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3HeadersSink.java.
Where is Http3HeadersSink defined?
Http3HeadersSink is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3HeadersSink.java at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free