Example #1
0
        public async Task Output()
        {
            _http1Connection.Reset();
            _http1Connection.StatusCode      = 200;
            _http1Connection.HttpVersionEnum = HttpVersion.Http11;
            _http1Connection.KeepAlive       = true;

            Task writeTask = Task.CompletedTask;

            switch (Type)
            {
            case BenchmarkTypes.TechEmpowerPlaintext:
                writeTask = TechEmpowerPlaintext();
                break;

            case BenchmarkTypes.PlaintextChunked:
                writeTask = PlaintextChunked();
                break;

            case BenchmarkTypes.PlaintextWithCookie:
                writeTask = PlaintextWithCookie();
                break;

            case BenchmarkTypes.PlaintextChunkedWithCookie:
                writeTask = PlaintextChunkedWithCookie();
                break;

            case BenchmarkTypes.LiveAspNet:
                writeTask = LiveAspNet();
                break;
            }

            await writeTask;
            await _http1Connection.ProduceEndAsync();
        }
Example #2
0
        public async Task RequestAbortedTokenIsResetBeforeLastWriteWithChunkedEncoding()
        {
            // Need to compare WaitHandle ref since CancellationToken is struct
            var original = _http1Connection.RequestAborted.WaitHandle;

            _http1Connection.HttpVersion = "HTTP/1.1";
            await _http1Connection.WriteAsync(new ArraySegment <byte>(Encoding.ASCII.GetBytes("hello, world")), default(CancellationToken));

            Assert.Same(original, _http1Connection.RequestAborted.WaitHandle);

            await _http1Connection.ProduceEndAsync();

            Assert.NotSame(original, _http1Connection.RequestAborted.WaitHandle);
        }
Example #3
0
        public async Task RequestAbortedTokenIsResetBeforeLastWriteWithChunkedEncoding()
        {
            var original = _http1Connection.RequestAborted;

            _http1Connection.HttpVersion = "HTTP/1.1";
            await _http1Connection.WriteAsync(new ArraySegment <byte>(Encoding.ASCII.GetBytes("hello, world")), default(CancellationToken));

            Assert.Equal(original, _http1Connection.RequestAborted);

            await _http1Connection.ProduceEndAsync();

            Assert.NotEqual(original, _http1Connection.RequestAborted);

            _http1Connection.Abort(new ConnectionAbortedException());

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