private void updateStreamReadWindow ( ) throws Http2Exception { if ( currentFrame instanceof FrameData ) { long frameSize = currentFrame . getPayloadLength ( ) ; streamReadWindowSize -= frameSize ; // decrement stream read window muxLink . connectionReadWindowSize -= frameSize ; // decrement connection read window // if the stream or connection windows become too small, update the windows // TODO: decide how often we should update the read window via WINDOW_UPDATE if ( streamReadWindowSize < ( muxLink . maxReadWindowSize / 2 ) || muxLink . connectionReadWindowSize < ( muxLink . maxReadWindowSize / 2 ) ) { int windowChange = ( int ) ( muxLink . maxReadWindowSize - this . streamReadWindowSize ) ; Frame savedFrame = currentFrame ; // save off the current frame if ( ! this . isStreamClosed ( ) ) { currentFrame = new FrameWindowUpdate ( myID , windowChange , false ) ; writeFrameSync ( ) ; currentFrame = savedFrame ; } long windowSizeIncrement = muxLink . getRemoteConnectionSettings ( ) . getMaxFrameSize ( ) ; FrameWindowUpdate wuf = new FrameWindowUpdate ( 0 , ( int ) windowSizeIncrement , false ) ; this . muxLink . getStream ( 0 ) . processNextFrame ( wuf , Direction . WRITING_OUT ) ; } } }
If this stream is receiving a DATA frame the local read window needs to be updated . If the read window drops below a threshold a WINDOW_UPDATE frame will be sent for both the connection and stream to update the windows .