Ejemplo n.º 1
0
        public async Task RequestAbortedTokenIsResetBeforeLastWriteWithContentLength()
        {
            _http1Connection.ResponseHeaders["Content-Length"] = "12";

            var original = _http1Connection.RequestAborted;

            foreach (var ch in "hello, worl")
            {
                await _http1Connection.WriteAsync(new ArraySegment <byte>(new[] { (byte)ch }));

                Assert.Equal(original, _http1Connection.RequestAborted);
            }

            await _http1Connection.WriteAsync(new ArraySegment <byte>(new[] { (byte)'d' }));

            Assert.NotEqual(original, _http1Connection.RequestAborted);

            _http1Connection.Abort(new ConnectionAbortedException());

            Assert.False(original.IsCancellationRequested);
            Assert.False(_http1Connection.RequestAborted.IsCancellationRequested);
        }