Home / Class/ ReadOnlyHttp2Headers Class — netty Architecture

ReadOnlyHttp2Headers Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb["ReadOnlyHttp2Headers"]
  298441ed_bdf2_76b6_011e_5ffe970f6cb8["ReadOnlyHttp2Headers.java"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|defined in| 298441ed_bdf2_76b6_011e_5ffe970f6cb8
  466686d5_70d1_4565_0126_7e7ac269b235["ReadOnlyHttp2Headers()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 466686d5_70d1_4565_0126_7e7ac269b235
  ae997f8b_38b4_f651_45b7_425e6e57008e["IllegalArgumentException()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| ae997f8b_38b4_f651_45b7_425e6e57008e
  e2210f38_16b0_b594_33ef_4243ca511d62["validateHeaders()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| e2210f38_16b0_b594_33ef_4243ca511d62
  6920423c_b3d5_ec88_b8f3_940f75926006["AsciiString()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 6920423c_b3d5_ec88_b8f3_940f75926006
  c0784bab_ac45_772a_cd5d_e5f7d8f6b2fd["CharSequence()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| c0784bab_ac45_772a_cd5d_e5f7d8f6b2fd
  1d98265b_7535_5a05_f712_0b35abe02993["getAll()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 1d98265b_7535_5a05_f712_0b35abe02993
  c52e9a4d_379a_d923_bd95_ff5b05597074["getAllAndRemove()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| c52e9a4d_379a_d923_bd95_ff5b05597074
  0748515c_6642_2097_1345_953b98e0dd26["Boolean()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 0748515c_6642_2097_1345_953b98e0dd26
  fbc1f879_77f3_feba_b97e_0fddf3e64d78["getBoolean()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| fbc1f879_77f3_feba_b97e_0fddf3e64d78
  471090e0_a451_9479_e85b_25bb257746c4["Byte()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 471090e0_a451_9479_e85b_25bb257746c4
  d594a060_7d45_306a_313f_0880ef703d49["getByte()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| d594a060_7d45_306a_313f_0880ef703d49
  7027e5c7_4333_8bbe_d72d_874abdbca1fe["Character()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 7027e5c7_4333_8bbe_d72d_874abdbca1fe
  3f1af2ec_1dbb_6cbb_7843_7daedade3e16["getChar()"]
  fb9ab82e_fa9f_006b_ddc8_d5545cd320cb -->|method| 3f1af2ec_1dbb_6cbb_7843_7daedade3e16

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java lines 46–892

public final class ReadOnlyHttp2Headers implements Http2Headers {
    private static final byte PSEUDO_HEADER_TOKEN = (byte) ':';
    private final AsciiString[] pseudoHeaders;
    private final AsciiString[] otherHeaders;

    /**
     * Used to create read only object designed to represent trailers.
     * <p>
     * If this is used for a purpose other than trailers you may violate the header serialization ordering defined by
     * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.1">RFC 7540, 8.1.2.1</a>.
     * @param validateHeaders {@code true} will run validation on each header name/value pair to ensure protocol
     *                        compliance.
     * @param otherHeaders An array of key:value pairs. Must not contain any
     *                     <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.1">pseudo headers</a>
     *                     or {@code null} names/values.
     *                     A copy will <strong>NOT</strong> be made of this array. If the contents of this array
     *                     may be modified externally you are responsible for passing in a copy.
     * @return A read only representation of the headers.
     */
    public static ReadOnlyHttp2Headers trailers(boolean validateHeaders, AsciiString... otherHeaders) {
        return new ReadOnlyHttp2Headers(validateHeaders, EMPTY_ASCII_STRINGS, otherHeaders);
    }

    /**
     * Create a new read only representation of headers used by clients.
     * @param validateHeaders {@code true} will run validation on each header name/value pair to ensure protocol
     *                        compliance.
     * @param method The value for {@link PseudoHeaderName#METHOD}.
     * @param path The value for {@link PseudoHeaderName#PATH}.
     * @param scheme The value for {@link PseudoHeaderName#SCHEME}.
     * @param authority The value for {@link PseudoHeaderName#AUTHORITY}.
     * @param otherHeaders An array of key:value pairs. Must not contain any
     *                     <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.1">pseudo headers</a>
     *                     or {@code null} names/values.
     *                     A copy will <strong>NOT</strong> be made of this array. If the contents of this array
     *                     may be modified externally you are responsible for passing in a copy.
     * @return a new read only representation of headers used by clients.
     */
    public static ReadOnlyHttp2Headers clientHeaders(boolean validateHeaders,
                                                     AsciiString method, AsciiString path,
                                                     AsciiString scheme, AsciiString authority,
                                                     AsciiString... otherHeaders) {
        return new ReadOnlyHttp2Headers(validateHeaders,
                new AsciiString[] {
                  PseudoHeaderName.METHOD.value(), method, PseudoHeaderName.PATH.value(), path,
                  PseudoHeaderName.SCHEME.value(), scheme, PseudoHeaderName.AUTHORITY.value(), authority
                },
                otherHeaders);
    }

    /**
     * Create a new read only representation of headers used by servers.
     * @param validateHeaders {@code true} will run validation on each header name/value pair to ensure protocol
     *                        compliance.
     * @param status The value for {@link PseudoHeaderName#STATUS}.
     * @param otherHeaders An array of key:value pairs. Must not contain any
     *                     <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.1">pseudo headers</a>
     *                     or {@code null} names/values.
     *                     A copy will <strong>NOT</strong> be made of this array. If the contents of this array
     *                     may be modified externally you are responsible for passing in a copy.
     * @return a new read only representation of headers used by servers.
     */
    public static ReadOnlyHttp2Headers serverHeaders(boolean validateHeaders,
                                                     AsciiString status,
                                                     AsciiString... otherHeaders) {
        return new ReadOnlyHttp2Headers(validateHeaders,
                                        new AsciiString[] { PseudoHeaderName.STATUS.value(), status },
                                        otherHeaders);
    }

    private ReadOnlyHttp2Headers(boolean validateHeaders, AsciiString[] pseudoHeaders, AsciiString... otherHeaders) {
        assert (pseudoHeaders.length & 1) == 0; // pseudoHeaders are only set internally so assert should be enough.
        if ((otherHeaders.length & 1) != 0) {
            throw newInvalidArraySizeException();
        }
        if (validateHeaders) {
            validateHeaders(pseudoHeaders, otherHeaders);
        }
        this.pseudoHeaders = pseudoHeaders;
        this.otherHeaders = otherHeaders;
    }

Frequently Asked Questions

What is the ReadOnlyHttp2Headers class?
ReadOnlyHttp2Headers is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java.
Where is ReadOnlyHttp2Headers defined?
ReadOnlyHttp2Headers is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java at line 46.

Analyze Your Own Codebase

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

Try Supermodel Free