Home / Class/ DefaultHttp2HeadersEncoder Class — netty Architecture

DefaultHttp2HeadersEncoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  d5205a77_8104_2f6b_7fe6_567c601fedb6["DefaultHttp2HeadersEncoder"]
  613f124b_e9d8_c77d_899b_037a77d7a86c["DefaultHttp2HeadersEncoder.java"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|defined in| 613f124b_e9d8_c77d_899b_037a77d7a86c
  89735714_5fa2_80c5_4bca_36436f9c24e3["DefaultHttp2HeadersEncoder()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| 89735714_5fa2_80c5_4bca_36436f9c24e3
  c895ec54_d8d8_81ce_5cf7_39cde7ba5751["encodeHeaders()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| c895ec54_d8d8_81ce_5cf7_39cde7ba5751
  16b45145_fe60_819d_66a2_863e1a1094dc["maxHeaderTableSize()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| 16b45145_fe60_819d_66a2_863e1a1094dc
  a9d7d3be_bae6_fb67_effe_2064d95b56df["maxHeaderListSize()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| a9d7d3be_bae6_fb67_effe_2064d95b56df
  cfa031cd_875f_65a8_955f_2ec9bc1dc9f2["Configuration()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| cfa031cd_875f_65a8_955f_2ec9bc1dc9f2
  b014a460_ef58_a002_0a8e_917568e2f765["close()"]
  d5205a77_8104_2f6b_7fe6_567c601fedb6 -->|method| b014a460_ef58_a002_0a8e_917568e2f765

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2HeadersEncoder.java lines 27–122

public class DefaultHttp2HeadersEncoder implements
    Http2HeadersEncoder, Http2HeadersEncoder.Configuration, Closeable {

    private final HpackEncoder hpackEncoder;
    private final SensitivityDetector sensitivityDetector;
    private ByteBuf tableSizeChangeOutput;

    public DefaultHttp2HeadersEncoder() {
        this(NEVER_SENSITIVE);
    }

    public DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector) {
        this(sensitivityDetector, new HpackEncoder());
    }

    public DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector, boolean ignoreMaxHeaderListSize) {
        this(sensitivityDetector, new HpackEncoder(ignoreMaxHeaderListSize));
    }

    public DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector, boolean ignoreMaxHeaderListSize,
                                      int dynamicTableArraySizeHint) {
        this(sensitivityDetector, ignoreMaxHeaderListSize, dynamicTableArraySizeHint, HpackEncoder.HUFF_CODE_THRESHOLD);
    }

    public DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector, boolean ignoreMaxHeaderListSize,
                                      int dynamicTableArraySizeHint, int huffCodeThreshold) {
        this(sensitivityDetector,
                new HpackEncoder(ignoreMaxHeaderListSize, dynamicTableArraySizeHint, huffCodeThreshold));
    }

    /**
     * Exposed Used for testing only! Default values used in the initial settings frame are overridden intentionally
     * for testing but violate the RFC if used outside the scope of testing.
     */
    DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector, HpackEncoder hpackEncoder) {
        this.sensitivityDetector = checkNotNull(sensitivityDetector, "sensitiveDetector");
        this.hpackEncoder = checkNotNull(hpackEncoder, "hpackEncoder");
    }

    @Override
    public void encodeHeaders(int streamId, Http2Headers headers, ByteBuf buffer) throws Http2Exception {
        try {
            // If there was a change in the table size, serialize the output from the hpackEncoder
            // resulting from that change.
            if (tableSizeChangeOutput != null && tableSizeChangeOutput.isReadable()) {
                buffer.writeBytes(tableSizeChangeOutput);
                tableSizeChangeOutput.clear();
            }

            hpackEncoder.encodeHeaders(streamId, buffer, headers, sensitivityDetector);
        } catch (Http2Exception e) {
            throw e;
        } catch (Throwable t) {
            throw connectionError(COMPRESSION_ERROR, t, "Failed encoding headers block: %s", t.getMessage());
        }
    }

    @Override
    public void maxHeaderTableSize(long max) throws Http2Exception {
        if (tableSizeChangeOutput == null) {
            tableSizeChangeOutput = Unpooled.buffer();
        }
        hpackEncoder.setMaxHeaderTableSize(tableSizeChangeOutput, max);
    }

    @Override
    public long maxHeaderTableSize() {
        return hpackEncoder.getMaxHeaderTableSize();
    }

    @Override
    public void maxHeaderListSize(long max) throws Http2Exception {
        hpackEncoder.setMaxHeaderListSize(max);
    }

    @Override
    public long maxHeaderListSize() {
        return hpackEncoder.getMaxHeaderListSize();
    }

    @Override

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free