Home / Class/ Http3ControlStreamOutboundHandler Class — netty Architecture

Http3ControlStreamOutboundHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  ac9fda69_8958_1431_6c61_8addd3cb4262["Http3ControlStreamOutboundHandler"]
  8663ebb0_28cc_a633_5fcd_4938b5348f48["Http3ControlStreamOutboundHandler.java"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|defined in| 8663ebb0_28cc_a633_5fcd_4938b5348f48
  0e3fdd09_ca46_068c_d61f_c583dc3f9530["Http3ControlStreamOutboundHandler()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| 0e3fdd09_ca46_068c_d61f_c583dc3f9530
  ff1a468a_8dda_488d_c098_90ce0c0affaf["Long()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| ff1a468a_8dda_488d_c098_90ce0c0affaf
  00b1d13d_6459_febf_81f0_12d6979c607f["channelActive()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| 00b1d13d_6459_febf_81f0_12d6979c607f
  4d33000f_41aa_ca75_a254_447f611e3c8a["userEventTriggered()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| 4d33000f_41aa_ca75_a254_447f611e3c8a
  eb30f846_ed3c_92bb_958c_6d7dc5501dd1["channelInactive()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| eb30f846_ed3c_92bb_958c_6d7dc5501dd1
  d88fa1e7_08f0_2f10_e0d6_0aba2015f5dd["write()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| d88fa1e7_08f0_2f10_e0d6_0aba2015f5dd
  275e4bd5_0916_ca9b_f54b_437fb8fcb013["handleHttp3MaxPushIdFrame()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| 275e4bd5_0916_ca9b_f54b_437fb8fcb013
  81a48989_57e3_2274_b5c8_7a237c2724a7["handleHttp3GoAwayFrame()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| 81a48989_57e3_2274_b5c8_7a237c2724a7
  d630cfba_a9dd_36ed_1788_d089ee1011d8["isSharable()"]
  ac9fda69_8958_1431_6c61_8addd3cb4262 -->|method| d630cfba_a9dd_36ed_1788_d089ee1011d8

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/Http3ControlStreamOutboundHandler.java lines 29–143

final class Http3ControlStreamOutboundHandler
        extends Http3FrameTypeDuplexValidationHandler<Http3ControlStreamFrame> {
    private final boolean server;
    private final ChannelHandler codec;
    private Long sentMaxPushId;
    private Long sendGoAwayId;
    private Http3SettingsFrame localSettings;

    Http3ControlStreamOutboundHandler(boolean server, Http3SettingsFrame localSettings, ChannelHandler codec) {
        super(Http3ControlStreamFrame.class);
        this.server = server;
        this.localSettings = ObjectUtil.checkNotNull(localSettings, "localSettings");
        this.codec = ObjectUtil.checkNotNull(codec, "codec");
    }

    /**
     * Returns the last id that was sent in a MAX_PUSH_ID frame or {@code null} if none was sent yet.
     *
     * @return the id.
     */
    @Nullable
    Long sentMaxPushId() {
        return sentMaxPushId;
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        // We need to write 0x00 into the stream before doing anything else.
        // See https://tools.ietf.org/html/draft-ietf-quic-http-32#section-6.2.1
        // Just allocate 8 bytes which would be the max needed.
        ByteBuf buffer = ctx.alloc().buffer(8);
        Http3CodecUtils.writeVariableLengthInteger(buffer, Http3CodecUtils.HTTP3_CONTROL_STREAM_TYPE);
        ctx.write(buffer);
        // Add the encoder and decoder in the pipeline so we can handle Http3Frames. This needs to happen after
        // we did write the type via a ByteBuf.
        ctx.pipeline().addFirst(codec);

        assert localSettings != null;
        // If writing of the local settings fails let's just teardown the connection.
        closeOnFailure(ctx.writeAndFlush(localSettings));

        // Let the GC collect localSettings.
        localSettings = null;

        ctx.fireChannelActive();
    }

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
        if (evt instanceof ChannelInputShutdownEvent) {
            // See https://tools.ietf.org/html/draft-ietf-quic-http-32#section-6.2.1
            Http3CodecUtils.criticalStreamClosed(ctx);
        }
        ctx.fireUserEventTriggered(evt);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) {
        // See https://tools.ietf.org/html/draft-ietf-quic-http-32#section-6.2.1
        Http3CodecUtils.criticalStreamClosed(ctx);
        ctx.fireChannelInactive();
    }

    @Override
    void write(ChannelHandlerContext ctx, Http3ControlStreamFrame msg, ChannelPromise promise) {
        if (msg instanceof Http3MaxPushIdFrame && !handleHttp3MaxPushIdFrame(promise, (Http3MaxPushIdFrame) msg)) {
            ReferenceCountUtil.release(msg);
            return;
        } else if (msg instanceof Http3GoAwayFrame && !handleHttp3GoAwayFrame(promise, (Http3GoAwayFrame) msg)) {
            ReferenceCountUtil.release(msg);
            return;
        }

        ctx.write(msg, promise);
    }

    private boolean handleHttp3MaxPushIdFrame(ChannelPromise promise, Http3MaxPushIdFrame maxPushIdFrame) {
        long id = maxPushIdFrame.id();

        // See https://datatracker.ietf.org/doc/html/draft-ietf-quic-http-32#section-7.2.7
        if (sentMaxPushId != null && id < sentMaxPushId) {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free