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