1 write to _http1Connection
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (1)
Http1\Http1ConnectionTestsBase.cs (1)
63_http1Connection = new TestHttp1Connection(_http1ConnectionContext);
198 references to _http1Connection
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (198)
Http1\Http1ConnectionTests.cs (198)
30_http1Connection.Reset(); 40Assert.Equal(headerValue, _http1Connection.RequestHeaders[headerName]); 49_http1Connection.Reset(); 64_http1Connection.Reset(); 75_http1Connection.Reset(); 92_http1Connection.Initialize(_http1ConnectionContext); 115_http1Connection.Reset(); 126Assert.True(_http1Connection.TakeStartLine(ref reader)); 127Assert.False(_http1Connection.TakeMessageHeaders(ref reader, trailers: false)); 133Assert.Empty(_http1Connection.RequestHeaders); 141Assert.True(_http1Connection.TakeMessageHeaders(ref reader, trailers: false)); 147Assert.Single(_http1Connection.RequestHeaders); 148Assert.Equal("makethislargerthanthestartline", _http1Connection.RequestHeaders["Header"]); 154_http1Connection.Scheme = "https"; 157_http1Connection.Reset(); 160Assert.Equal("http", ((IFeatureCollection)_http1Connection).Get<IHttpRequestFeature>().Scheme); 166_http1Connection.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 1, gracePeriod: TimeSpan.MaxValue); 168_http1Connection.Reset(); 170Assert.Same(_serviceContext.ServerOptions.Limits.MinRequestBodyDataRate, _http1Connection.MinRequestBodyDataRate); 176_http1Connection.MinResponseDataRate = new MinDataRate(bytesPerSecond: 1, gracePeriod: TimeSpan.MaxValue); 178_http1Connection.Reset(); 180Assert.Same(_serviceContext.ServerOptions.Limits.MinResponseDataRate, _http1Connection.MinResponseDataRate); 187var feature = ((IFeatureCollection)_http1Connection).Get<IHttpRequestIdentifierFeature>(); 189var requestProcessingTask = _http1Connection.ProcessRequestsAsync(new DummyApplication()); 249_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout); 256_http1Connection.TraceIdentifier = null; 257var id = _http1Connection.TraceIdentifier; 259Assert.Equal(id, _http1Connection.TraceIdentifier); 280Assert.Single(_http1Connection.RequestHeaders); 281Assert.Equal("value1", _http1Connection.RequestHeaders["Header-1"]); 283_http1Connection.Reset(); 292Assert.Single(_http1Connection.RequestHeaders); 293Assert.Equal("value2", _http1Connection.RequestHeaders["Header-2"]); 300await _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1])); 303Assert.True(_http1Connection.HasResponseStarted); 304Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status404NotFound); 311await _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1])); 314Assert.True(_http1Connection.HasResponseStarted); 315Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).ReasonPhrase = "Reason phrase"); 321await _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1])); 324Assert.True(_http1Connection.HasResponseStarted); 325Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).OnStarting(_ => Task.CompletedTask, null)); 332((IFeatureCollection)_http1Connection).Get<IHttpMinRequestBodyDataRateFeature>().MinDataRate = minDataRate; 334Assert.Same(minDataRate, _http1Connection.MinRequestBodyDataRate); 341((IFeatureCollection)_http1Connection).Get<IHttpMinResponseDataRateFeature>().MinDataRate = minDataRate; 343Assert.Same(minDataRate, _http1Connection.MinResponseDataRate); 350var originalRequestHeaders = _http1Connection.RequestHeaders; 351_http1Connection.RequestHeaders = new HttpRequestHeaders(); 354_http1Connection.Reset(); 357Assert.Same(originalRequestHeaders, _http1Connection.RequestHeaders); 364var originalResponseHeaders = _http1Connection.ResponseHeaders; 365_http1Connection.ResponseHeaders = new HttpResponseHeaders(); 368_http1Connection.Reset(); 371Assert.Same(originalResponseHeaders, _http1Connection.ResponseHeaders); 378var messageBody = Http1MessageBody.For(Kestrel.Core.Internal.Http.HttpVersion.Http11, (HttpRequestHeaders)_http1Connection.RequestHeaders, _http1Connection); 379_http1Connection.InitializeBodyControl(messageBody); 381var originalRequestBody = _http1Connection.RequestBody; 382var originalResponseBody = _http1Connection.ResponseBody; 383_http1Connection.RequestBody = new MemoryStream(); 384_http1Connection.ResponseBody = new MemoryStream(); 387_http1Connection.InitializeBodyControl(messageBody); 390Assert.Same(originalRequestBody, _http1Connection.RequestBody); 391Assert.Same(originalResponseBody, _http1Connection.ResponseBody); 417Assert.Equal(expectedMethod, ((IHttpRequestFeature)_http1Connection).Method); 418Assert.Equal(expectedRawTarget, _http1Connection.RawTarget); 419Assert.Equal(expectedDecodedPath, _http1Connection.Path); 420Assert.Equal(expectedQueryString, _http1Connection.QueryString); 421Assert.Equal(expectedHttpVersion, _http1Connection.HttpVersion); 440Assert.Equal(expectedRawTarget, _http1Connection.RawTarget); 441Assert.Equal(expectedDecodedPath, _http1Connection.Path); 442Assert.Equal(expectedQueryString, _http1Connection.QueryString); 573var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null); 578_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout); 588((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status304NotModified; 591await Assert.ThrowsAsync<InvalidOperationException>(() => _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1]))); 598_http1Connection.HttpVersion = "HTTP/1.1"; 599((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status304NotModified; 602await Assert.ThrowsAsync<InvalidOperationException>(() => _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1]), default(CancellationToken))); 609_http1Connection.HttpVersion = "HTTP/1.1"; 610_http1Connection.Method = HttpMethod.Head; 613await _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1])); 620_http1Connection.HttpVersion = "HTTP/1.1"; 621_http1Connection.Method = HttpMethod.Head; 624await _http1Connection.WriteAsync(new ArraySegment<byte>(new byte[1]), default(CancellationToken)); 631_http1Connection.HttpVersion = "HTTP/1.1"; 632_http1Connection.Method = HttpMethod.Head; 635_http1Connection.ResponseHeaders.Add("Transfer-Encoding", "chunked"); 638await Assert.ThrowsAsync<InvalidOperationException>(() => _http1Connection.FlushAsync()); 645_http1Connection.HttpVersion = "HTTP/1.1"; 646((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status304NotModified; 649_http1Connection.ResponseHeaders.Add("Transfer-Encoding", "chunked"); 652await Assert.ThrowsAsync<InvalidOperationException>(() => _http1Connection.FlushAsync()); 658var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null); 663_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout); 673_http1Connection.ResponseHeaders["Content-Length"] = "12"; 675var original = _http1Connection.RequestAborted; 679await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)ch })); 680Assert.Equal(original, _http1Connection.RequestAborted); 683await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)'d' })); 684Assert.NotEqual(original, _http1Connection.RequestAborted); 686_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 689Assert.False(_http1Connection.RequestAborted.IsCancellationRequested); 695_http1Connection.ResponseHeaders["Content-Length"] = "12"; 697var original = _http1Connection.RequestAborted; 701await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)ch }), default(CancellationToken)); 702Assert.Equal(original, _http1Connection.RequestAborted); 705await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)'d' }), default(CancellationToken)); 706Assert.NotEqual(original, _http1Connection.RequestAborted); 708_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 711Assert.False(_http1Connection.RequestAborted.IsCancellationRequested); 723_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 724var failResult = await _http1Connection.FlushPipeAsync(new CancellationToken()); 737_http1Connection.CancelPendingFlush(); 739var canceledResult = await _http1Connection.FlushPipeAsync(new CancellationToken()); 743var goodResult = await _http1Connection.FlushPipeAsync(new CancellationToken()); 750_http1Connection.ResponseHeaders["Content-Length"] = "12"; 752var original = _http1Connection.RequestAborted; 755var startingTask = _http1Connection.InitializeResponseAwaited(Task.CompletedTask, 1); 756await _http1Connection.WriteAsyncAwaited(startingTask, new ArraySegment<byte>(new[] { (byte)'h' }), default(CancellationToken)); 757Assert.Equal(original, _http1Connection.RequestAborted); 761await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)ch }), default(CancellationToken)); 762Assert.Equal(original, _http1Connection.RequestAborted); 765await _http1Connection.WriteAsync(new ArraySegment<byte>(new[] { (byte)'d' }), default(CancellationToken)); 766Assert.NotEqual(original, _http1Connection.RequestAborted); 768_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 771Assert.False(_http1Connection.RequestAborted.IsCancellationRequested); 777var original = _http1Connection.RequestAborted; 779_http1Connection.HttpVersion = "HTTP/1.1"; 780await _http1Connection.WriteAsync(new ArraySegment<byte>(Encoding.ASCII.GetBytes("hello, world")), default(CancellationToken)); 781Assert.Equal(original, _http1Connection.RequestAborted); 783await _http1Connection.ProduceEndAsync(); 784Assert.NotEqual(original, _http1Connection.RequestAborted); 786_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 789Assert.False(_http1Connection.RequestAborted.IsCancellationRequested); 795var originalToken = _http1Connection.RequestAborted; 798_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 801Assert.True(_http1Connection.RequestAborted.WaitHandle.WaitOne(TestConstants.DefaultTimeout)); 809var originalToken = _http1Connection.RequestAborted; 812_http1Connection.Abort(new ConnectionAbortedException(), ConnectionEndReason.AbortedByApp); 817Assert.True(_http1Connection.RequestAborted.WaitHandle.WaitOne(TestConstants.DefaultTimeout)); 825var originalToken = _http1Connection.RequestAborted; 830await _http1Connection.WritePipeAsync(ReadOnlyMemory<byte>.Empty, default).DefaultTimeout(); 833Assert.True(_http1Connection.RequestAborted.WaitHandle.WaitOne(TestConstants.DefaultTimeout)); 875var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null); 878await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders != null); 879Assert.Empty(_http1Connection.RequestHeaders); 882await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count); 883Assert.Equal(header0Count, _http1Connection.RequestHeaders.Count); 886await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count); 887Assert.Equal(header0Count + header1Count, _http1Connection.RequestHeaders.Count); 907var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null); 910await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders != null); 911Assert.Empty(_http1Connection.RequestHeaders); 913var newRequestHeaders = new RequestHeadersWrapper(_http1Connection.RequestHeaders); 914_http1Connection.RequestHeaders = newRequestHeaders; 915Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders); 918await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count); 919Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders); 920Assert.Equal(header0Count, _http1Connection.RequestHeaders.Count); 923await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count); 924Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders); 925Assert.Equal(header0Count + header1Count, _http1Connection.RequestHeaders.Count); 936_http1Connection.HasStartedConsumingRequestBody = true; 939Assert.True(((IHttpMaxRequestBodySizeFeature)_http1Connection).IsReadOnly); 940var ex = Assert.Throws<InvalidOperationException>(() => ((IHttpMaxRequestBodySizeFeature)_http1Connection).MaxRequestBodySize = 1); 948var ex = Assert.Throws<ArgumentOutOfRangeException>(() => ((IHttpMaxRequestBodySizeFeature)_http1Connection).MaxRequestBodySize = -1); 961_http1Connection.NextMessageBody = mockMessageBody.Object; 963var requestProcessingTask = _http1Connection.ProcessRequestsAsync(httpApplication); 975_http1Connection.HttpVersion = "HTTP/1.0"; 976_http1Connection.EnsureHostHeaderExists(); 982_http1Connection.HttpVersion = "HTTP/1.0"; 983_http1Connection.RequestHeaders.Host = "localhost:5000"; 984_http1Connection.EnsureHostHeaderExists(); 990_http1Connection.HttpVersion = "HTTP/1.1"; 991_http1Connection.RequestHeaders.Host = ""; 992_http1Connection.EnsureHostHeaderExists(); 998_http1Connection.HttpVersion = "HTTP/1.1"; 999_http1Connection.RequestHeaders.Host = "localhost:5000"; 1000_http1Connection.EnsureHostHeaderExists(); 1006_http1Connection.HttpVersion = "HTTP/1.0"; 1007_http1Connection.RequestHeaders.Host = "a=b"; 1008var ex = Assert.ThrowsAny<Http.BadHttpRequestException>(() => _http1Connection.EnsureHostHeaderExists()); 1015_http1Connection.HttpVersion = "HTTP/1.1"; 1016_http1Connection.RequestHeaders.Host = "a=b"; 1017var ex = Assert.ThrowsAny<Http.BadHttpRequestException>(() => _http1Connection.EnsureHostHeaderExists()); 1026_http1Connection.RequestHeaders.Add(HeaderNames.ContentLength, contentLength); 1027_http1Connection.RequestHeaders.Add(HeaderNames.TransferEncoding, "chunked"); 1030Http1MessageBody.For(Kestrel.Core.Internal.Http.HttpVersion.Http11, (HttpRequestHeaders)_http1Connection.RequestHeaders, _http1Connection); 1033Assert.True(_http1Connection.RequestHeaders.ContainsKey("X-Content-Length")); 1034Assert.Equal(contentLength, _http1Connection.RequestHeaders["X-Content-Length"]); 1035Assert.True(_http1Connection.RequestHeaders.ContainsKey(HeaderNames.TransferEncoding)); 1036Assert.Equal("chunked", _http1Connection.RequestHeaders[HeaderNames.TransferEncoding]); 1037Assert.False(_http1Connection.RequestHeaders.ContainsKey(HeaderNames.ContentLength)); 1043if (_http1Connection.TakeMessageHeaders(ref reader, trailers: trailers)) 1060if (_http1Connection.TakeStartLine(ref reader)) 1077if (_http1Connection.ParseRequest(ref reader))