Home / Class/ SpdySessionHandler Class — netty Architecture

SpdySessionHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  1fb79984_fd8e_cecc_3934_20ed3529f561["SpdySessionHandler"]
  f4d095fa_ab64_f79a_595e_5930c189e5a3["SpdySessionHandler.java"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|defined in| f4d095fa_ab64_f79a_595e_5930c189e5a3
  bf5e2abd_3722_694d_4d7f_3eddc9a50c0a["SpdySessionHandler()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| bf5e2abd_3722_694d_4d7f_3eddc9a50c0a
  a7318d77_ffe9_30f5_6445_00b268135cd7["setSessionReceiveWindowSize()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| a7318d77_ffe9_30f5_6445_00b268135cd7
  d2ae1d21_cf0c_c4d0_e046_efc746940057["channelRead()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| d2ae1d21_cf0c_c4d0_e046_efc746940057
  72436298_62de_b647_5c7a_939caa744c7e["channelInactive()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 72436298_62de_b647_5c7a_939caa744c7e
  499a8c9f_7814_300b_956d_2810cc0d0209["exceptionCaught()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 499a8c9f_7814_300b_956d_2810cc0d0209
  96f50bec_02a0_531a_3389_0cbbc84594d9["close()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 96f50bec_02a0_531a_3389_0cbbc84594d9
  07a6926c_53d4_0712_b28c_9bfc902c90c9["write()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 07a6926c_53d4_0712_b28c_9bfc902c90c9
  ec4cd550_8624_c011_7fc2_e23fed71bcc1["handleOutboundMessage()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| ec4cd550_8624_c011_7fc2_e23fed71bcc1
  d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1["issueSessionError()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1
  523c4082_b738_2187_2ebe_17c60a486843["issueStreamError()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 523c4082_b738_2187_2ebe_17c60a486843
  05b1923a_38e1_1014_132a_6e3154a42d84["isRemoteInitiatedId()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 05b1923a_38e1_1014_132a_6e3154a42d84
  a307b408_3c7d_1a80_235f_83be0b78429e["updateInitialSendWindowSize()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| a307b408_3c7d_1a80_235f_83be0b78429e
  7458b225_6f9a_5cab_a9c4_c8f352e67d6c["updateInitialReceiveWindowSize()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561 -->|method| 7458b225_6f9a_5cab_a9c4_c8f352e67d6c

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java lines 34–841

public class SpdySessionHandler extends ChannelDuplexHandler {

    private static final SpdyProtocolException PROTOCOL_EXCEPTION =
            SpdyProtocolException.newStatic(null, SpdySessionHandler.class, "handleOutboundMessage(...)");
    private static final SpdyProtocolException STREAM_CLOSED =
            SpdyProtocolException.newStatic("Stream closed", SpdySessionHandler.class, "removeStream(...)");

    private static final int DEFAULT_WINDOW_SIZE = 64 * 1024; // 64 KB default initial window size
    private int initialSendWindowSize    = DEFAULT_WINDOW_SIZE;
    private int initialReceiveWindowSize = DEFAULT_WINDOW_SIZE;
    private volatile int initialSessionReceiveWindowSize = DEFAULT_WINDOW_SIZE;

    private final SpdySession spdySession = new SpdySession(initialSendWindowSize, initialReceiveWindowSize);
    private int lastGoodStreamId;

    private static final int DEFAULT_MAX_CONCURRENT_STREAMS = Integer.MAX_VALUE;
    private int remoteConcurrentStreams = DEFAULT_MAX_CONCURRENT_STREAMS;
    private int localConcurrentStreams  = DEFAULT_MAX_CONCURRENT_STREAMS;

    private final AtomicInteger pings = new AtomicInteger();

    private boolean sentGoAwayFrame;
    private boolean receivedGoAwayFrame;

    private ChannelFutureListener closeSessionFutureListener;

    private final boolean server;
    private final int minorVersion;

    /**
     * Creates a new session handler.
     *
     * @param version the protocol version
     * @param server  {@code true} if and only if this session handler should
     *                handle the server endpoint of the connection.
     *                {@code false} if and only if this session handler should
     *                handle the client endpoint of the connection.
     */
    public SpdySessionHandler(SpdyVersion version, boolean server) {
        this.minorVersion = ObjectUtil.checkNotNull(version, "version").minorVersion();
        this.server = server;
    }

    public void setSessionReceiveWindowSize(int sessionReceiveWindowSize) {
        checkPositiveOrZero(sessionReceiveWindowSize, "sessionReceiveWindowSize");
        // This will not send a window update frame immediately.
        // If this value increases the allowed receive window size,
        // a WINDOW_UPDATE frame will be sent when only half of the
        // session window size remains during data frame processing.
        // If this value decreases the allowed receive window size,
        // the window will be reduced as data frames are processed.
        initialSessionReceiveWindowSize = sessionReceiveWindowSize;
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof SpdyDataFrame) {

            /*
             * SPDY Data frame processing requirements:
             *
             * If an endpoint receives a data frame for a Stream-ID which is not open
             * and the endpoint has not sent a GOAWAY frame, it must issue a stream error
             * with the error code INVALID_STREAM for the Stream-ID.
             *
             * If an endpoint which created the stream receives a data frame before receiving
             * a SYN_REPLY on that stream, it is a protocol error, and the recipient must
             * issue a stream error with the getStatus code PROTOCOL_ERROR for the Stream-ID.
             *
             * If an endpoint receives multiple data frames for invalid Stream-IDs,
             * it may close the session.
             *
             * If an endpoint refuses a stream it must ignore any data frames for that stream.
             *
             * If an endpoint receives a data frame after the stream is half-closed from the
             * sender, it must send a RST_STREAM frame with the getStatus STREAM_ALREADY_CLOSED.
             *
             * If an endpoint receives a data frame after the stream is closed, it must send
             * a RST_STREAM frame with the getStatus PROTOCOL_ERROR.
             */
            SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;

Frequently Asked Questions

What is the SpdySessionHandler class?
SpdySessionHandler is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java.
Where is SpdySessionHandler defined?
SpdySessionHandler is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free