Exemplo n.º 1
0
        public TestInput()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(pool: _memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            Transport   = pair.Transport;
            Application = pair.Application;

            var connectionFeatures = new FeatureCollection();

            connectionFeatures.Set(Mock.Of <IConnectionLifetimeFeature>());
            connectionFeatures.Set(Mock.Of <IBytesWrittenFeature>());

            Http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = new TestServiceContext(),
                ConnectionFeatures = connectionFeatures,
                Application        = Application,
                Transport          = Transport,
                MemoryPool         = _memoryPool,
                TimeoutControl     = Mock.Of <ITimeoutControl>()
            };

            Http1Connection = new Http1Connection(Http1ConnectionContext);
            Http1Connection.HttpResponseControl = Mock.Of <IHttpResponseControl>();
        }
Exemplo n.º 2
0
        public void Setup()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair       = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = new ServiceContext
            {
                ServerOptions = new KestrelServerOptions(),
                HttpParser    = NullParser <Http1ParsingHandler> .Instance
            };

            var http1Connection = new Http1Connection(context: new HttpConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                TimeoutControl     = new TimeoutControl(timeoutHandler: null),
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            Connection = http1Connection;
        }
Exemplo n.º 3
0
        public HttpProtocolFeatureCollection()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var pair       = DuplexPipe.CreateConnectionPair(memoryPool);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new Http1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _collection = http1Connection;
        }
Exemplo n.º 4
0
        public HttpProtocolFeatureCollectionTests()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _transport   = pair.Transport;
            _application = pair.Application;

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
            _collection = _http1Connection;
        }
        public HttpConnectionTests()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            var connectionFeatures = new FeatureCollection();

            connectionFeatures.Set(Mock.Of <IConnectionLifetimeFeature>());
            connectionFeatures.Set(Mock.Of <IBytesWrittenFeature>());

            _httpConnectionContext = new HttpConnectionContext
            {
                ConnectionId       = "0123456789",
                ConnectionContext  = Mock.Of <ConnectionContext>(),
                ConnectionAdapters = new List <IConnectionAdapter>(),
                ConnectionFeatures = connectionFeatures,
                MemoryPool         = _memoryPool,
                HttpConnectionId   = long.MinValue,
                Transport          = pair.Transport,
                ServiceContext     = new TestServiceContext
                {
                    SystemClock = new SystemClock()
                }
            };

            _httpConnection = new HttpConnection(_httpConnectionContext);
        }
        public void Setup()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);

            _pair = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                TimeoutControl     = new MockTimeoutControl(),
                Application        = _pair.Application,
                Transport          = _pair.Transport
            });

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Exemplo n.º 7
0
        public StartLineTests()
        {
            MemoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(MemoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            Transport = pair.Transport;

            var serviceContext = new ServiceContext
            {
                ServerOptions = new KestrelServerOptions(),
                Log           = _trace,
                HttpParser    = new HttpParser <Http1ParsingHandler>()
            };

            Http1Connection = new Http1Connection(context: new HttpConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = MemoryPool,
                Transport          = Transport,
                TimeoutControl     = new TimeoutControl(timeoutHandler: null)
            });

            Parser         = new HttpParser <Http1ParsingHandler>(showErrorDetails: true);
            ParsingHandler = new Http1ParsingHandler(Http1Connection);
        }
Exemplo n.º 8
0
 static TSocket()
 {
     using (var memoryPool = KestrelMemoryPool.Create())
     {
         MaxPooledBlockLength = memoryPool.MaxBufferSize;
     }
 }
Exemplo n.º 9
0
        public HttpProtocolFeatureCollection()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair       = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new Http1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _collection = http1Connection;
        }
Exemplo n.º 10
0
        public void Setup()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var pair = DuplexPipe.CreateConnectionPair(_memoryPool);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new Http1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                Application        = pair.Application,
                Transport          = pair.Transport,
                TimeoutControl     = new MockTimeoutControl()
            });

            http1Connection.Reset();

            Http1Connection = http1Connection;
            Pipe            = new Pipe(new PipeOptions(_memoryPool));
        }
Exemplo n.º 11
0
        public Http1ConnectionTests()
        {
            _pipelineFactory = KestrelMemoryPool.Create();
            var options = new PipeOptions(_pipelineFactory, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _transport   = pair.Transport;
            _application = pair.Application;

            var connectionFeatures = new FeatureCollection();

            connectionFeatures.Set(Mock.Of <IConnectionLifetimeFeature>());
            connectionFeatures.Set(Mock.Of <IBytesWrittenFeature>());

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionContext  = Mock.Of <ConnectionContext>(),
                ConnectionFeatures = connectionFeatures,
                MemoryPool         = _pipelineFactory,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
        }
Exemplo n.º 12
0
        public void InitialDictionaryIsEmpty()
        {
            using (var memoryPool = KestrelMemoryPool.Create())
            {
                var options = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
                var pair    = DuplexPipe.CreateConnectionPair(options, options);
                var http1ConnectionContext = new HttpConnectionContext
                {
                    ServiceContext     = new TestServiceContext(),
                    ConnectionFeatures = new FeatureCollection(),
                    MemoryPool         = memoryPool,
                    Transport          = pair.Transport,
                    TimeoutControl     = null
                };

                var http1Connection = new Http1Connection(http1ConnectionContext);

                http1Connection.Reset();

                IDictionary <string, StringValues> headers = http1Connection.ResponseHeaders;

                Assert.Equal(0, headers.Count);
                Assert.False(headers.IsReadOnly);
            }
        }
Exemplo n.º 13
0
        public void InitialDictionaryIsEmpty()
        {
            using (var memoryPool = KestrelMemoryPool.Create())
            {
                var pair = DuplexPipe.CreateConnectionPair(memoryPool);
                var http1ConnectionContext = new Http1ConnectionContext
                {
                    ServiceContext     = new TestServiceContext(),
                    ConnectionFeatures = new FeatureCollection(),
                    MemoryPool         = memoryPool,
                    Application        = pair.Application,
                    Transport          = pair.Transport,
                    TimeoutControl     = null
                };

                var http1Connection = new Http1Connection(http1ConnectionContext);

                http1Connection.Reset();

                IDictionary <string, StringValues> headers = http1Connection.ResponseHeaders;

                Assert.Equal(0, headers.Count);
                Assert.False(headers.IsReadOnly);
            }
        }
Exemplo n.º 14
0
        public void Setup()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var pair       = DuplexPipe.CreateConnectionPair(memoryPool);

            var serviceContext = new ServiceContext
            {
                ServerOptions = new KestrelServerOptions(),
                HttpParser    = NullParser <Http1ParsingHandler> .Instance
            };

            var http1Connection = new Http1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                TimeoutControl     = new MockTimeoutControl(),
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Exemplo n.º 15
0
        public void Setup()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var pipe = new Pipe(new PipeOptions(_memoryPool));

            _reader = pipe.Reader;
            _writer = pipe.Writer;
        }
Exemplo n.º 16
0
 public MemoryPool <byte> Create()
 {
     lock (_pools)
     {
         var pool = new DiagnosticMemoryPool(KestrelMemoryPool.CreateSlabMemoryPool(), _allowLateReturn, _rentTracking);
         _pools.Add(pool);
         return(pool);
     }
 }
Exemplo n.º 17
0
        public LibuvOutputConsumerTests()
        {
            _memoryPool = KestrelMemoryPool.Create();
            _mockLibuv  = new MockLibuv();

            var libuvTransport = new LibuvTransport(_mockLibuv, new TestLibuvTransportContext(), new ListenOptions((ulong)0));

            _libuvThread = new LibuvThread(libuvTransport, maxLoops: 1);
            _libuvThread.StartAsync().Wait();
        }
        public void Setup()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair       = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = _dateHeaderValueManager,
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new Http1Connection(new HttpConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                Transport          = pair.Transport
            });

            http1Connection.Reset();
            serviceContext.DateHeaderValueManager.OnHeartbeat(DateTimeOffset.UtcNow);

            _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders;
            var context = new DefaultHttpContext(http1Connection);

            _response = new DefaultHttpResponse(context);

            switch (Type)
            {
            case BenchmarkTypes.ContentLengthNumeric:
                ContentLengthNumeric(1);
                break;

            case BenchmarkTypes.ContentLengthString:
                ContentLengthString(1);
                break;

            case BenchmarkTypes.Plaintext:
                Plaintext(1);
                break;

            case BenchmarkTypes.Common:
                Common(1);
                break;

            case BenchmarkTypes.Unknown:
                Unknown(1);
                break;
            }
        }
        public void Setup()
        {
            var memoryPool = KestrelMemoryPool.Create();
            var pair       = DuplexPipe.CreateConnectionPair(memoryPool);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new Http1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = memoryPool,
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders;
            var context = new DefaultHttpContext(http1Connection);

            _response = new DefaultHttpResponse(context);

            switch (Type)
            {
            case BenchmarkTypes.ContentLengthNumeric:
                ContentLengthNumeric(1);
                break;

            case BenchmarkTypes.ContentLengthString:
                ContentLengthString(1);
                break;

            case BenchmarkTypes.Plaintext:
                Plaintext(1);
                break;

            case BenchmarkTypes.Common:
                Common(1);
                break;

            case BenchmarkTypes.Unknown:
                Unknown(1);
                break;
            }
        }
Exemplo n.º 20
0
        public LibuvThread(LibuvTransport transport)
        {
            _transport   = transport;
            _appLifetime = transport.AppLifetime;
            _log         = transport.Log;
            _loop        = new UvLoopHandle(_log);
            _post        = new UvAsyncHandle(_log);
            _thread      = new Thread(ThreadStart);
            _thread.Name = nameof(LibuvThread);
#if !DEBUG
            // Mark the thread as being as unimportant to keeping the process alive.
            // Don't do this for debug builds, so we know if the thread isn't terminating.
            _thread.IsBackground = true;
#endif
            QueueCloseHandle      = PostCloseHandle;
            QueueCloseAsyncHandle = EnqueueCloseHandle;
            MemoryPool            = KestrelMemoryPool.Create();
            WriteReqPool          = new WriteReqPool(this, _log);
        }
Exemplo n.º 21
0
        public TestInput()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var pair = DuplexPipe.CreateConnectionPair(_memoryPool);

            Transport   = pair.Transport;
            Application = pair.Application;

            Http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = new TestServiceContext(),
                ConnectionFeatures = new FeatureCollection(),
                Application        = Application,
                Transport          = Transport,
                MemoryPool         = _memoryPool,
                TimeoutControl     = Mock.Of <ITimeoutControl>()
            };

            Http1Connection = new Http1Connection(Http1ConnectionContext);
            Http1Connection.HttpResponseControl = Mock.Of <IHttpResponseControl>();
        }
        public HttpConnectionTests()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var pair = DuplexPipe.CreateConnectionPair(_memoryPool);

            _httpConnectionContext = new HttpConnectionContext
            {
                ConnectionId       = "0123456789",
                ConnectionAdapters = new List <IConnectionAdapter>(),
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                HttpConnectionId   = long.MinValue,
                Application        = pair.Application,
                Transport          = pair.Transport,
                ServiceContext     = new TestServiceContext
                {
                    SystemClock = new SystemClock()
                }
            };

            _httpConnection = new HttpConnection(_httpConnectionContext);
        }
        public Http1ConnectionTests()
        {
            _pipelineFactory = KestrelMemoryPool.Create();
            var pair = DuplexPipe.CreateConnectionPair(_pipelineFactory);

            _transport   = pair.Transport;
            _application = pair.Application;

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _pipelineFactory,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
        }
Exemplo n.º 24
0
 public void Setup()
 {
     _memoryPool = KestrelMemoryPool.Create();
     _pipe       = new Pipe(new PipeOptions(_memoryPool));
 }
Exemplo n.º 25
0
 public void GlobalSetup()
 {
     _memoryPool      = KestrelMemoryPool.Create();
     _http1Connection = MakeHttp1Connection();
 }
 internal static MemoryPool <byte> CreateMemoryPool()
 {
     return(KestrelMemoryPool.Create());
 }
 internal static MemoryPool <byte> CreateMemoryPool()
 {
     // TODO: remove duplicate code
     return(KestrelMemoryPool.Create());
 }
 public OutputProducerTests()
 {
     _memoryPool = KestrelMemoryPool.Create();
 }
Exemplo n.º 29
0
        public void OutputPipeOptionsConfiguredCorrectly(long? maxResponseBufferSize, long expectedMaximumSizeLow, long expectedMaximumSizeHigh)
        {
            var serviceContext = new TestServiceContext();
            serviceContext.ServerOptions.Limits.MaxResponseBufferSize = maxResponseBufferSize;
            serviceContext.Scheduler = PipeScheduler.ThreadPool;

            var mockScheduler = Mock.Of<PipeScheduler>();
            var outputPipeOptions = ConnectionHandler.GetOutputPipeOptions(serviceContext, KestrelMemoryPool.Create(), readerScheduler: mockScheduler);

            Assert.Equal(expectedMaximumSizeLow, outputPipeOptions.ResumeWriterThreshold);
            Assert.Equal(expectedMaximumSizeHigh, outputPipeOptions.PauseWriterThreshold);
            Assert.Same(mockScheduler, outputPipeOptions.ReaderScheduler);
            Assert.Same(serviceContext.Scheduler, outputPipeOptions.WriterScheduler);
        }
Exemplo n.º 30
0
        public async Task CopyToAsyncDoesNotCopyBlocks()
        {
            var writeCount      = 0;
            var writeTcs        = new TaskCompletionSource <(byte[], int, int)>();
            var mockDestination = new Mock <Stream>()
            {
                CallBase = true
            };

            mockDestination
            .Setup(m => m.WriteAsync(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>(), CancellationToken.None))
            .Callback((byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
            {
                writeTcs.SetResult((buffer, offset, count));
                writeCount++;
            })
            .Returns(Task.CompletedTask);

            using (var memoryPool = KestrelMemoryPool.Create())
            {
                var options                = new PipeOptions(pool: memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
                var pair                   = DuplexPipe.CreateConnectionPair(options, options);
                var transport              = pair.Transport;
                var application            = pair.Application;
                var http1ConnectionContext = new Http1ConnectionContext
                {
                    ServiceContext     = new TestServiceContext(),
                    ConnectionFeatures = new FeatureCollection(),
                    Application        = application,
                    Transport          = transport,
                    MemoryPool         = memoryPool,
                    TimeoutControl     = Mock.Of <ITimeoutControl>()
                };
                var http1Connection = new Http1Connection(http1ConnectionContext)
                {
                    HasStartedConsumingRequestBody = true
                };

                var headers = new HttpRequestHeaders {
                    HeaderContentLength = "12"
                };
                var body = Http1MessageBody.For(HttpVersion.Http11, headers, http1Connection);

                var copyToAsyncTask = body.CopyToAsync(mockDestination.Object);

                var bytes  = Encoding.ASCII.GetBytes("Hello ");
                var buffer = http1Connection.RequestBodyPipe.Writer.GetMemory(2048);
                ArraySegment <byte> segment;
                Assert.True(MemoryMarshal.TryGetArray(buffer, out segment));
                Buffer.BlockCopy(bytes, 0, segment.Array, segment.Offset, bytes.Length);
                http1Connection.RequestBodyPipe.Writer.Advance(bytes.Length);
                await http1Connection.RequestBodyPipe.Writer.FlushAsync();

                // Verify the block passed to Stream.WriteAsync() is the same one incoming data was written into.
                Assert.Equal((segment.Array, segment.Offset, bytes.Length), await writeTcs.Task);

                // Verify the again when GetMemory returns the tail space of the same block.
                writeTcs = new TaskCompletionSource <(byte[], int, int)>();
                bytes    = Encoding.ASCII.GetBytes("World!");
                buffer   = http1Connection.RequestBodyPipe.Writer.GetMemory(2048);
                Assert.True(MemoryMarshal.TryGetArray(buffer, out segment));
                Buffer.BlockCopy(bytes, 0, segment.Array, segment.Offset, bytes.Length);
                http1Connection.RequestBodyPipe.Writer.Advance(bytes.Length);
                await http1Connection.RequestBodyPipe.Writer.FlushAsync();

                Assert.Equal((segment.Array, segment.Offset, bytes.Length), await writeTcs.Task);

                http1Connection.RequestBodyPipe.Writer.Complete();

                await copyToAsyncTask;

                Assert.Equal(2, writeCount);

                // Don't call body.StopAsync() because PumpAsync() was never called.
                http1Connection.RequestBodyPipe.Reader.Complete();
            }
        }