Esempio n. 1
0
        private void HandleDataFrame(DataFrame dataFrame, out Http2Stream stream)
        {
            Http2Logger.LogDebug("DATA frame: stream id={0}, payload len={1}, has pad={2}, pad high={3}, pad low={4}, " +
                                 "end stream={5}", dataFrame.StreamId, dataFrame.PayloadLength,
                                 dataFrame.HasPadding, dataFrame.PadHigh, dataFrame.PadLow, dataFrame.IsEndStream);

            /* 12 -> 6.1
             * DATA frames MUST be associated with a stream. If a DATA frame is
             * received whose stream identifier field is 0x0, the recipient MUST
             * respond with a connection error of type PROTOCOL_ERROR. */
            if (dataFrame.StreamId == 0)
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError,
                                        "Incoming continuation frame with stream id=0");
            }

            /* 12 -> 6.1
             * An endpoint that has not enabled DATA frame compression MUST
             * treat the receipt of a DATA frame with the COMPRESSED flag set as a
             * connection error of type PROTOCOL_ERROR. */
            if (dataFrame.IsCompressed)
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError,
                                        "GZIP compression is not enabled");
            }

            stream = GetStream(dataFrame.StreamId);

            if (stream.Closed)
            {
                throw new Http2StreamNotFoundException(dataFrame.StreamId);
            }

            if (!(stream.Opened || stream.HalfClosedLocal))
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError, "data in non opened or half closed local stream");
            }


            if (stream.IsFlowControlEnabled && !dataFrame.IsEndStream)
            {
                stream.WriteWindowUpdate(Constants.MaxFramePayloadSize);
            }
        }
        private void HandleDataFrame(DataFrame dataFrame, out Http2Stream stream)
        {
            stream = GetStream(dataFrame.StreamId);

            //Aggressive window update
            if (stream != null)
            {
                Http2Logger.LogDebug("Data frame. StreamId: {0} Length: {1}", dataFrame.StreamId,
                                     dataFrame.FrameLength);
                if (stream.IsFlowControlEnabled)
                {
                    stream.WriteWindowUpdate(Constants.MaxFrameContentSize);
                }
            }
            else
            {
                throw new Http2StreamNotFoundException(dataFrame.StreamId);
            }
        }
        private void HandleDataFrame(DataFrame dataFrame, out Http2Stream stream)
        {
            //09 -> 6.1.  DATA
            //DATA frames MUST be associated with a stream.  If a DATA frame is
            //received whose stream identifier field is 0x0, the recipient MUST
            //respond with a connection error (Section 5.4.1) of type
            //PROTOCOL_ERROR.
            if (dataFrame.StreamId == 0)
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError,
                                        "Incoming continuation frame with id = 0");
            }

            stream = GetStream(dataFrame.StreamId);

            //Aggressive window update
            if (stream != null)
            {
                Http2Logger.LogDebug("Data frame. StreamId: {0} Length: {1}", dataFrame.StreamId,
                                     dataFrame.FrameLength);
                if (stream.IsFlowControlEnabled)
                {
                    stream.WriteWindowUpdate(Constants.MaxFrameContentSize);
                }
            }
            else
            {
                throw new Http2StreamNotFoundException(dataFrame.StreamId);
            }
        }
        private void HandleDataFrame(DataFrame dataFrame, out Http2Stream stream)
        {
            Http2Logger.LogDebug("DATA frame: stream id={0}, payload len={1}, has pad={2}, pad high={3}, pad low={4}, " +
                                 "end stream={5}", dataFrame.StreamId, dataFrame.PayloadLength, 
                                 dataFrame.HasPadding, dataFrame.PadHigh, dataFrame.PadLow, dataFrame.IsEndStream);
            /* 12 -> 6.1
            DATA frames MUST be associated with a stream. If a DATA frame is
            received whose stream identifier field is 0x0, the recipient MUST 
            respond with a connection error of type PROTOCOL_ERROR. */
            if (dataFrame.StreamId == 0)
                throw new ProtocolError(ResetStatusCode.ProtocolError,
                                        "Incoming continuation frame with stream id=0");
            /* 12 -> 6.1 
            An endpoint that has not enabled DATA frame compression MUST
            treat the receipt of a DATA frame with the COMPRESSED flag set as a
            connection error of type PROTOCOL_ERROR. */
            if (dataFrame.IsCompressed)
                throw new ProtocolError(ResetStatusCode.ProtocolError,
                                        "GZIP compression is not enabled");

            stream = GetStream(dataFrame.StreamId);

            if (stream.Closed)
                throw new Http2StreamNotFoundException(dataFrame.StreamId);

            if (!(stream.Opened || stream.HalfClosedLocal))
                throw new ProtocolError(ResetStatusCode.ProtocolError, "data in non opened or half closed local stream");

            
            if (stream.IsFlowControlEnabled && !dataFrame.IsEndStream)
            {
                stream.WriteWindowUpdate(Constants.MaxFramePayloadSize);
            }
        }