public void Initialize(Http2StreamContext context) { base.Initialize(context); _decrementCalled = false; _completionState = StreamCompletionFlags.None; InputRemaining = null; RequestBodyStarted = false; DrainExpirationTicks = 0; _context = context; _inputFlowControl = new StreamInputFlowControl( context.StreamId, context.FrameWriter, context.ConnectionInputFlowControl, context.ServerPeerSettings.InitialWindowSize, context.ServerPeerSettings.InitialWindowSize / 2); _outputFlowControl = new StreamOutputFlowControl( context.ConnectionOutputFlowControl, context.ClientPeerSettings.InitialWindowSize); _http2Output = new Http2OutputProducer( context.StreamId, context.FrameWriter, _outputFlowControl, context.MemoryPool, this, context.ServiceContext.Log); RequestBodyPipe = CreateRequestBodyPipe(context.ServerPeerSettings.InitialWindowSize); Output = _http2Output; }
private (StreamCompletionFlags OldState, StreamCompletionFlags NewState) ApplyCompletionFlag(StreamCompletionFlags completionState) { lock (_completionLock) { var oldCompletionState = _completionState; _completionState |= completionState; return(oldCompletionState, _completionState); } }
public void Initialize(Http3StreamContext context) { base.Initialize(context); InputRemaining = null; _context = context; _errorCodeFeature = _context.ConnectionFeatures.GetRequiredFeature <IProtocolErrorCodeFeature>(); _streamIdFeature = _context.ConnectionFeatures.GetRequiredFeature <IStreamIdFeature>(); _streamAbortFeature = _context.ConnectionFeatures.GetRequiredFeature <IStreamAbortFeature>(); _appCompletedTaskSource.Reset(); _isClosed = 0; _requestHeaderParsingState = default; _parsedPseudoHeaderFields = default; _totalParsedHeaderSize = 0; _isMethodConnect = false; _completionState = default; StreamTimeoutTicks = 0; if (_frameWriter == null) { _frameWriter = new Http3FrameWriter( context.StreamContext, context.TimeoutControl, context.ServiceContext.ServerOptions.Limits.MinResponseDataRate, context.MemoryPool, context.ServiceContext.Log, _streamIdFeature, context.ClientPeerSettings, this); _http3Output = new Http3OutputProducer( _frameWriter, context.MemoryPool, this, context.ServiceContext.Log); Output = _http3Output; RequestBodyPipe = CreateRequestBodyPipe(64 * 1024); // windowSize? QPackDecoder = new QPackDecoder(_context.ServiceContext.ServerOptions.Limits.Http3.MaxRequestHeaderFieldSize); } else { _http3Output.StreamReset(); RequestBodyPipe.Reset(); QPackDecoder.Reset(); } _frameWriter.Reset(context.Transport.Output, context.ConnectionId); }
private static bool ShoulStopTrackingStream(StreamCompletionFlags completionState) { // This could be a single condition, but I think it reads better as two if's. if ((completionState & StreamCompletionFlags.RequestProcessingEnded) == StreamCompletionFlags.RequestProcessingEnded) { if ((completionState & StreamCompletionFlags.EndStreamReceived) == StreamCompletionFlags.EndStreamReceived || (completionState & StreamCompletionFlags.Aborted) == StreamCompletionFlags.Aborted) { return(true); } } return(false); }
private bool TryApplyCompletionFlag(StreamCompletionFlags completionState) { lock (_completionLock) { var lastCompletionState = _completionState; _completionState |= completionState; if (ShoulStopTrackingStream(_completionState) && !ShoulStopTrackingStream(lastCompletionState)) { _context.StreamLifetimeHandler.OnStreamCompleted(StreamId); } return(_completionState != lastCompletionState); } }
public void Initialize(Http2StreamContext context) { base.Initialize(context); CanReuse = false; _decrementCalled = false; _completionState = StreamCompletionFlags.None; InputRemaining = null; RequestBodyStarted = false; DrainExpirationTicks = 0; _context = context; // First time the stream is used we need to create flow control, producer and pipes. // When a stream is reused these types will be reset and reused. if (_inputFlowControl == null) { _inputFlowControl = new StreamInputFlowControl( this, context.FrameWriter, context.ConnectionInputFlowControl, context.ServerPeerSettings.InitialWindowSize, context.ServerPeerSettings.InitialWindowSize / 2); _outputFlowControl = new StreamOutputFlowControl( context.ConnectionOutputFlowControl, context.ClientPeerSettings.InitialWindowSize); _http2Output = new Http2OutputProducer(this, context, _outputFlowControl); RequestBodyPipe = CreateRequestBodyPipe(); Output = _http2Output; } else { _inputFlowControl.Reset(); _outputFlowControl.Reset(context.ClientPeerSettings.InitialWindowSize); _http2Output.StreamReset(); RequestBodyPipe.Reset(); } }