Home / Class/ Http2ConnectionHandler Class — netty Architecture

Http2ConnectionHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  a9ab361d_2417_0366_d9d0_ae1adb2145dc["Http2ConnectionHandler"]
  9c883019_01e3_e30b_1c79_24fbb727545e["Http2ConnectionHandler.java"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|defined in| 9c883019_01e3_e30b_1c79_24fbb727545e
  9d6e703a_cdde_97a0_cc17_00d96e62239e["Http2ConnectionHandler()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 9d6e703a_cdde_97a0_cc17_00d96e62239e
  0f7996ec_b4a7_c1f5_6e23_3465950f9417["gracefulShutdownTimeoutMillis()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 0f7996ec_b4a7_c1f5_6e23_3465950f9417
  28b4179f_56cf_bd00_dc06_65ea52bc10b2["Http2Connection()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 28b4179f_56cf_bd00_dc06_65ea52bc10b2
  9033a4d4_21a1_090c_6b68_c6bc05b11517["Http2ConnectionDecoder()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 9033a4d4_21a1_090c_6b68_c6bc05b11517
  85f7c4b8_83b5_58e5_500d_da9da4599c88["Http2ConnectionEncoder()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 85f7c4b8_83b5_58e5_500d_da9da4599c88
  7ac4a90e_d0ae_14a9_10cc_cd77b04bff6c["prefaceSent()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 7ac4a90e_d0ae_14a9_10cc_cd77b04bff6c
  62ad413b_566d_e31b_30b0_3e314fc8865c["onHttpClientUpgrade()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 62ad413b_566d_e31b_30b0_3e314fc8865c
  d777a039_1711_835b_0843_da9b11ca161d["onHttpServerUpgrade()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| d777a039_1711_835b_0843_da9b11ca161d
  fcfd6790_7b31_2514_7e7e_6ee61c0daff9["flush()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| fcfd6790_7b31_2514_7e7e_6ee61c0daff9
  ca10094c_9de4_bcf4_308b_1cc8f0f6b72b["handlerAdded()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| ca10094c_9de4_bcf4_308b_1cc8f0f6b72b
  b8c8742e_9a6d_3ad7_5282_d9880cc38fa5["handlerRemoved0()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| b8c8742e_9a6d_3ad7_5282_d9880cc38fa5
  8dee1709_f11e_ea83_5fa1_f29f61281e95["channelActive()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| 8dee1709_f11e_ea83_5fa1_f29f61281e95
  ff42c156_99e8_6424_922e_4748014af503["channelInactive()"]
  a9ab361d_2417_0366_d9d0_ae1adb2145dc -->|method| ff42c156_99e8_6424_922e_4748014af503

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java lines 64–994

public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http2LifecycleManager,
                                                                            ChannelOutboundHandler {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2ConnectionHandler.class);

    private static final Http2Headers HEADERS_TOO_LARGE_HEADERS = ReadOnlyHttp2Headers.serverHeaders(false,
            HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE.codeAsText());
    private static final ByteBuf HTTP_1_X_BUF = Unpooled.unreleasableBuffer(
        Unpooled.wrappedBuffer(new byte[] {'H', 'T', 'T', 'P', '/', '1', '.'})).asReadOnly();

    private final Http2ConnectionDecoder decoder;
    private final Http2ConnectionEncoder encoder;
    private final Http2Settings initialSettings;
    private final boolean decoupleCloseAndGoAway;
    private final boolean flushPreface;
    private ChannelFutureListener closeListener;
    private BaseDecoder byteDecoder;
    private long gracefulShutdownTimeoutMillis;

    protected Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
                                     Http2Settings initialSettings) {
        this(decoder, encoder, initialSettings, false);
    }

    protected Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
                                     Http2Settings initialSettings, boolean decoupleCloseAndGoAway) {
        this(decoder, encoder, initialSettings, decoupleCloseAndGoAway, true);
    }

    protected Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
                                     Http2Settings initialSettings, boolean decoupleCloseAndGoAway,
                                     boolean flushPreface) {
        this.initialSettings = checkNotNull(initialSettings, "initialSettings");
        this.decoder = checkNotNull(decoder, "decoder");
        this.encoder = checkNotNull(encoder, "encoder");
        this.decoupleCloseAndGoAway = decoupleCloseAndGoAway;
        this.flushPreface = flushPreface;
        if (encoder.connection() != decoder.connection()) {
            throw new IllegalArgumentException("Encoder and Decoder do not share the same connection object");
        }
    }

    /**
     * Get the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing
     * the connection during the graceful shutdown process. Returns -1 if this connection is configured to wait
     * indefinitely for all streams to close.
     */
    public long gracefulShutdownTimeoutMillis() {
        return gracefulShutdownTimeoutMillis;
    }

    /**
     * Set the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing
     * the connection during the graceful shutdown process.
     * @param gracefulShutdownTimeoutMillis the amount of time (in milliseconds) this endpoint will wait for all
     * streams to be closed before closing the connection during the graceful shutdown process.
     */
    public void gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis) {
        if (gracefulShutdownTimeoutMillis < -1) {
            throw new IllegalArgumentException("gracefulShutdownTimeoutMillis: " + gracefulShutdownTimeoutMillis +
                                               " (expected: -1 for indefinite or >= 0)");
        }
        this.gracefulShutdownTimeoutMillis = gracefulShutdownTimeoutMillis;
    }

    public Http2Connection connection() {
        return encoder.connection();
    }

    public Http2ConnectionDecoder decoder() {
        return decoder;
    }

    public Http2ConnectionEncoder encoder() {
        return encoder;
    }

    private boolean prefaceSent() {
        return byteDecoder != null && byteDecoder.prefaceSent();
    }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free