channelRead() — netty Function Reference
Architecture documentation for the channelRead() function in SpdySessionHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d2ae1d21_cf0c_c4d0_e046_efc746940057["channelRead()"] 1fb79984_fd8e_cecc_3934_20ed3529f561["SpdySessionHandler"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|defined in| 1fb79984_fd8e_cecc_3934_20ed3529f561 d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1["issueSessionError()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1 523c4082_b738_2187_2ebe_17c60a486843["issueStreamError()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| 523c4082_b738_2187_2ebe_17c60a486843 05b1923a_38e1_1014_132a_6e3154a42d84["isRemoteInitiatedId()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| 05b1923a_38e1_1014_132a_6e3154a42d84 fd4b4a14_de0e_f563_d7f8_c8f51694e4f6["halfCloseStream()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| fd4b4a14_de0e_f563_d7f8_c8f51694e4f6 48161a49_383a_2f23_c7eb_f67d5d02bbc6["acceptStream()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| 48161a49_383a_2f23_c7eb_f67d5d02bbc6 9259efc1_c40e_efc0_2d75_ce800778ec12["removeStream()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| 9259efc1_c40e_efc0_2d75_ce800778ec12 a307b408_3c7d_1a80_235f_83be0b78429e["updateInitialSendWindowSize()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| a307b408_3c7d_1a80_235f_83be0b78429e 0bbd9d3a_603a_1f42_0a30_c790b2a786c5["updateSendWindowSize()"] d2ae1d21_cf0c_c4d0_e046_efc746940057 -->|calls| 0bbd9d3a_603a_1f42_0a30_c790b2a786c5 style d2ae1d21_cf0c_c4d0_e046_efc746940057 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java lines 88–411
@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;
int streamId = spdyDataFrame.streamId();
int deltaWindowSize = -1 * spdyDataFrame.content().readableBytes();
int newSessionWindowSize =
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, deltaWindowSize);
// Check if session window size is reduced beyond allowable lower bound
if (newSessionWindowSize < 0) {
issueSessionError(ctx, SpdySessionStatus.PROTOCOL_ERROR);
return;
}
// Send a WINDOW_UPDATE frame if less than half the session window size remains
if (newSessionWindowSize <= initialSessionReceiveWindowSize / 2) {
int sessionDeltaWindowSize = initialSessionReceiveWindowSize - newSessionWindowSize;
spdySession.updateReceiveWindowSize(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
SpdyWindowUpdateFrame spdyWindowUpdateFrame =
new DefaultSpdyWindowUpdateFrame(SPDY_SESSION_STREAM_ID, sessionDeltaWindowSize);
ctx.writeAndFlush(spdyWindowUpdateFrame);
}
// Check if we received a data frame for a Stream-ID which is not open
if (!spdySession.isActiveStream(streamId)) {
spdyDataFrame.release();
if (streamId <= lastGoodStreamId) {
issueStreamError(ctx, streamId, SpdyStreamStatus.PROTOCOL_ERROR);
} else if (!sentGoAwayFrame) {
issueStreamError(ctx, streamId, SpdyStreamStatus.INVALID_STREAM);
}
return;
}
// Check if we received a data frame for a stream which is half-closed
if (spdySession.isRemoteSideClosed(streamId)) {
spdyDataFrame.release();
issueStreamError(ctx, streamId, SpdyStreamStatus.STREAM_ALREADY_CLOSED);
return;
}
// Check if we received a data frame before receiving a SYN_REPLY
if (!isRemoteInitiatedId(streamId) && !spdySession.hasReceivedReply(streamId)) {
spdyDataFrame.release();
issueStreamError(ctx, streamId, SpdyStreamStatus.PROTOCOL_ERROR);
return;
}
/*
* SPDY Data frame flow control processing requirements:
*
* Recipient should not send a WINDOW_UPDATE frame as it consumes the last data frame.
*/
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does channelRead() do?
channelRead() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java.
Where is channelRead() defined?
channelRead() is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java at line 88.
What does channelRead() call?
channelRead() calls 8 function(s): acceptStream, halfCloseStream, isRemoteInitiatedId, issueSessionError, issueStreamError, removeStream, updateInitialSendWindowSize, updateSendWindowSize.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free