public Http2FrameWriter( PipeWriter outputPipeWriter, BaseConnectionContext connectionContext, Http2Connection http2Connection, OutputFlowControl connectionOutputFlowControl, ITimeoutControl timeoutControl, MinDataRate?minResponseDataRate, string connectionId, MemoryPool <byte> memoryPool, ServiceContext serviceContext) { // Allow appending more data to the PipeWriter when a flush is pending. _outputWriter = new ConcurrentPipeWriter(outputPipeWriter, memoryPool, _writeLock); _connectionContext = connectionContext; _http2Connection = http2Connection; _connectionOutputFlowControl = connectionOutputFlowControl; _connectionId = connectionId; _log = serviceContext.Log; _timeoutControl = timeoutControl; _minResponseDataRate = minResponseDataRate; _flusher = new TimingPipeFlusher(timeoutControl, serviceContext.Log); _flusher.Initialize(_outputWriter); _outgoingFrame = new Http2Frame(); _headerEncodingBuffer = new byte[_maxFrameSize]; _scheduleInline = serviceContext.Scheduler == PipeScheduler.Inline; _hpackEncoder = new DynamicHPackEncoder(serviceContext.ServerOptions.AllowResponseHeaderCompression); }
public async Task PassthroughIfAllFlushesAreAwaited() { using (var slabPool = new SlabMemoryPool()) using (var diagnosticPool = new DiagnosticMemoryPool(slabPool)) { var pipeWriterFlushTcsArray = new[] { new TaskCompletionSource <FlushResult>(TaskCreationOptions.RunContinuationsAsynchronously), new TaskCompletionSource <FlushResult>(TaskCreationOptions.RunContinuationsAsynchronously), }; var sync = new object(); var mockPipeWriter = new MockPipeWriter(pipeWriterFlushTcsArray); var concurrentPipeWriter = new ConcurrentPipeWriter(mockPipeWriter, diagnosticPool, sync); ValueTask <FlushResult> flushTask; lock (sync) { var memory = concurrentPipeWriter.GetMemory(); Assert.Equal(1, mockPipeWriter.GetMemoryCallCount); concurrentPipeWriter.Advance(memory.Length); Assert.Equal(1, mockPipeWriter.AdvanceCallCount); flushTask = concurrentPipeWriter.FlushAsync(); Assert.Equal(1, mockPipeWriter.FlushCallCount); pipeWriterFlushTcsArray[0].SetResult(default);
public Http1OutputProducer( PipeWriter pipeWriter, string connectionId, ConnectionContext connectionContext, IKestrelTrace log, ITimeoutControl timeoutControl, IHttpMinResponseDataRateFeature minResponseDataRateFeature, MemoryPool <byte> memoryPool) { // Allow appending more data to the PipeWriter when a flush is pending. _pipeWriter = new ConcurrentPipeWriter(pipeWriter, memoryPool, _contextLock); _connectionId = connectionId; _connectionContext = connectionContext; _log = log; _minResponseDataRateFeature = minResponseDataRateFeature; _flusher = new TimingPipeFlusher(_pipeWriter, timeoutControl, log); _memoryPool = memoryPool; }
public Http2OutputProducer(Http2Stream stream, Http2StreamContext context, StreamOutputFlowControl flowControl) { _stream = stream; _frameWriter = context.FrameWriter; _flowControl = flowControl; _memoryPool = context.MemoryPool; _log = context.ServiceContext.Log; _pipe = CreateDataPipe(_memoryPool); _pipeWriter = new ConcurrentPipeWriter(_pipe.Writer, _memoryPool, _dataWriterLock); _pipeReader = _pipe.Reader; // No need to pass in timeoutControl here, since no minDataRates are passed to the TimingPipeFlusher. // The minimum output data rate is enforced at the connection level by Http2FrameWriter. _flusher = new TimingPipeFlusher(_pipeWriter, timeoutControl: null, _log); _dataWriteProcessingTask = ProcessDataWrites(); }
public Http2OutputProducer(Http2Stream stream, Http2StreamContext context) { _stream = stream; _frameWriter = context.FrameWriter; _memoryPool = context.MemoryPool; _log = context.ServiceContext.Log; var scheduleInline = context.ServiceContext.Scheduler == PipeScheduler.Inline; _pipe = CreateDataPipe(_memoryPool, scheduleInline); _pipeWriter = new ConcurrentPipeWriter(_pipe.Writer, _memoryPool, _dataWriterLock); _pipeReader = _pipe.Reader; // No need to pass in timeoutControl here, since no minDataRates are passed to the TimingPipeFlusher. // The minimum output data rate is enforced at the connection level by Http2FrameWriter. _flusher = new TimingPipeFlusher(timeoutControl: null, _log); _flusher.Initialize(_pipeWriter); _streamWindow = context.ClientPeerSettings.InitialWindowSize; }
public Http2FrameWriter( PipeWriter outputPipeWriter, ConnectionContext connectionContext, Http2Connection http2Connection, OutputFlowControl connectionOutputFlowControl, ITimeoutControl timeoutControl, MinDataRate minResponseDataRate, string connectionId, MemoryPool <byte> memoryPool, IKestrelTrace log) { // Allow appending more data to the PipeWriter when a flush is pending. _outputWriter = new ConcurrentPipeWriter(outputPipeWriter, memoryPool, _writeLock); _connectionContext = connectionContext; _http2Connection = http2Connection; _connectionOutputFlowControl = connectionOutputFlowControl; _connectionId = connectionId; _log = log; _timeoutControl = timeoutControl; _minResponseDataRate = minResponseDataRate; _flusher = new TimingPipeFlusher(_outputWriter, timeoutControl, log); _outgoingFrame = new Http2Frame(); _headerEncodingBuffer = new byte[_maxFrameSize]; }