Home / Class/ Http3PushStreamServerInitializer Class — netty Architecture

Http3PushStreamServerInitializer Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  5411b28f_c5aa_5274_8700_02211c848104["Http3PushStreamServerInitializer"]
  8001bfb9_a133_e4f7_d68f_162ff6b9c134["Http3PushStreamServerInitializer.java"]
  5411b28f_c5aa_5274_8700_02211c848104 -->|defined in| 8001bfb9_a133_e4f7_d68f_162ff6b9c134
  79abd19c_b5ce_63c5_660e_ffedf4d27485["Http3PushStreamServerInitializer()"]
  5411b28f_c5aa_5274_8700_02211c848104 -->|method| 79abd19c_b5ce_63c5_660e_ffedf4d27485
  27446036_bdb8_8391_0927_55f5a35d44ff["initChannel()"]
  5411b28f_c5aa_5274_8700_02211c848104 -->|method| 27446036_bdb8_8391_0927_55f5a35d44ff
  8e7232b8_925c_b8c8_c701_467fd4bd4f50["initPushStream()"]
  5411b28f_c5aa_5274_8700_02211c848104 -->|method| 8e7232b8_925c_b8c8_c701_467fd4bd4f50

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/Http3PushStreamServerInitializer.java lines 32–79

public abstract class Http3PushStreamServerInitializer extends ChannelInitializer<QuicStreamChannel> {

    private final long pushId;

    protected Http3PushStreamServerInitializer(long pushId) {
        this.pushId = checkPositiveOrZero(pushId, "pushId");
    }

    @Override
    protected final void initChannel(QuicStreamChannel ch) {
        if (!isServerInitiatedQuicStream(ch)) {
            throw new IllegalArgumentException("Using server push stream initializer for client stream: " +
                    ch.streamId());
        }
        Http3CodecUtils.verifyIsUnidirectional(ch);

        // We need to write stream type into the stream before doing anything else.
        // See https://tools.ietf.org/html/draft-ietf-quic-http-32#section-6.2.1
        // Just allocate 16 bytes which would be the max needed to write 2 variable length ints.
        ByteBuf buffer = ch.alloc().buffer(16);
        writeVariableLengthInteger(buffer, Http3CodecUtils.HTTP3_PUSH_STREAM_TYPE);
        writeVariableLengthInteger(buffer, pushId);
        ch.write(buffer);

        Http3ConnectionHandler connectionHandler = Http3CodecUtils.getConnectionHandlerOrClose(ch.parent());
        if (connectionHandler == null) {
            // connection should have been closed
            return;
        }

        ChannelPipeline pipeline = ch.pipeline();
        Http3RequestStreamEncodeStateValidator encodeStateValidator = new Http3RequestStreamEncodeStateValidator();
        // Add the encoder and decoder in the pipeline so we can handle Http3Frames
        pipeline.addLast(connectionHandler.newCodec(encodeStateValidator, NO_STATE));
        pipeline.addLast(encodeStateValidator);
        // Add the handler that will validate what we write and receive on this stream.
        pipeline.addLast(connectionHandler.newPushStreamValidationHandler(ch, NO_STATE));
        initPushStream(ch);
    }

    /**
     * Initialize the {@link QuicStreamChannel} to handle {@link Http3PushStreamFrame}s. At the point of calling this
     * method it is already valid to write {@link Http3PushStreamFrame}s as the codec is already in the pipeline.
     *
     * @param ch the {QuicStreamChannel} for the push stream.
     */
    protected abstract void initPushStream(QuicStreamChannel ch);
}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free