Base:
property
Request
Microsoft.AspNetCore.Http.HttpContext.Request
34 writes to Request
Microsoft.AspNetCore.Http.Extensions.Tests (2)
ParameterBindingMethodCacheTests.cs (2)
237Request = 268Request =
Microsoft.AspNetCore.Mvc.Core.Test (6)
Routing\UrlHelperExtensionsTest.cs (6)
611Request = 646Request = 681Request = 719Request = 767Request = 815Request =
Microsoft.AspNetCore.Mvc.RazorPages.Test (16)
ApplicationModels\DefaultPageApplicationModelProviderTest.cs (1)
992Request =
Infrastructure\DefaultPageHandlerMethodSelectorTest.cs (15)
39Request = 87Request = 138Request = 182Request = 218Request = 261Request = 311Request = 361Request = 412Request = 456Request = 507Request = 552Request = 602Request = 652Request = 712Request =
Microsoft.AspNetCore.Routing.Tests (10)
Builder\EndpointRoutingApplicationBuilderExtensionsTest.cs (1)
273requestDelegate(new DefaultHttpContext() { Request = { Path = "/Foo", }, });
EndpointRoutingMiddlewareFormOptionsTest.cs (1)
194Request =
Matching\AcceptsMatcherPolicyTest.cs (8)
388Request = 415Request = 442Request = 469Request = 496Request = 523Request = 552Request = 581Request =
933 references to Request
HttpAbstractions.SampleApp (1)
Program.cs (1)
14var request = context.Request;
Microsoft.AspNetCore.Antiforgery.Test (2)
AntiforgeryMiddlewareTest.cs (2)
22httpContext.Request.Method = method; 54httpContext.Request.Method = method;
Microsoft.AspNetCore.Components.Endpoints.Tests (14)
EndpointHtmlRendererTest.cs (10)
758ctx.Request.Scheme = "http"; 759ctx.Request.Host = new HostString("localhost"); 760ctx.Request.PathBase = "/base"; 761ctx.Request.Path = "/path"; 762ctx.Request.QueryString = new QueryString("?query=value"); 789ctx.Request.Scheme = "http"; 790ctx.Request.Host = new HostString("localhost"); 791ctx.Request.PathBase = "/base"; 792ctx.Request.Path = "/path"; 793ctx.Request.QueryString = new QueryString("?query=value");
RazorComponentEndpointInvokerTest.cs (2)
43context.Request.Method = "POST"; 44context.Request.ContentType = "application/json";
RazorComponentResultTest.cs (2)
472result.Request.Scheme = "https"; 473result.Request.Host = new HostString("test");
Microsoft.AspNetCore.Components.Server.Tests (17)
CircuitDisconnectMiddlewareTest.cs (17)
35context.Request.Method = httpMethod; 63context.Request.Method = HttpMethods.Post; 64context.Request.ContentType = contentType; 90context.Request.Method = HttpMethods.Post; 91context.Request.ContentType = "application/x-www-form-urlencoded"; 121context.Request.Method = HttpMethods.Post; 122context.Request.ContentType = "application/x-www-form-urlencoded"; 123context.Request.Body = memory; 154context.Request.Method = HttpMethods.Post; 155context.Request.ContentType = "application/x-www-form-urlencoded"; 156context.Request.Body = memory; 191context.Request.Method = HttpMethods.Post; 192context.Request.ContentType = "application/x-www-form-urlencoded"; 193context.Request.Body = memory; 229context.Request.Method = HttpMethods.Post; 230context.Request.ContentType = "application/x-www-form-urlencoded"; 231context.Request.Body = memory;
Microsoft.AspNetCore.Components.WebAssembly.Server.Tests (27)
ContentEncodingNegotiatorTests.cs (27)
23httpContext.Request.Path = "/_framework/blazor.boot.json"; 24httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 28Assert.Equal(expectedPath, httpContext.Request.Path); 45httpContext.Request.Path = "/_framework/blazor.boot.json"; 46httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 50Assert.Equal(expectedPath, httpContext.Request.Path); 66httpContext.Request.Path = "/_framework/blazor.boot.json"; 67httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 71Assert.Equal(expectedPath, httpContext.Request.Path); 89httpContext.Request.Path = "/_framework/blazor.boot.json"; 90httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 94Assert.Equal(expectedPath, httpContext.Request.Path); 112httpContext.Request.Path = "/_framework/blazor.boot.json"; 113httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 117Assert.Equal(expectedPath, httpContext.Request.Path); 135httpContext.Request.Path = "/_framework/blazor.boot.json"; 136httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 140Assert.Equal(expectedPath, httpContext.Request.Path); 158httpContext.Request.Path = "/_framework/blazor.boot.json"; 159httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 163Assert.Equal(expectedPath, httpContext.Request.Path); 180httpContext.Request.Path = "/_framework/blazor.boot.json"; 181httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 185Assert.Equal(expectedPath, httpContext.Request.Path); 201httpContext.Request.Path = "/_framework/blazor.boot.json"; 202httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 206Assert.Equal(expectedPath, httpContext.Request.Path);
Microsoft.AspNetCore.Cors.Test (24)
CorsMiddlewareTests.cs (20)
392httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 421httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 658httpContext.Request.Method = "OPTIONS"; 659httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { OriginUrl }); 660httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "PUT" }); 700httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 730httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 757httpContext.Request.Method = "OPTIONS"; 758httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 759httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "GET" }); 789httpContext.Request.Method = "GET"; 790httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 791httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "GET" }); 822httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 857httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 894httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 927httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 957httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 984httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 1032httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" });
CorsServiceTests.cs (4)
953context.Request.Method = method; 958context.Request.Headers.Add(CorsConstants.Origin, new[] { origin }); 963context.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { accessControlRequestMethod }); 968context.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, accessControlRequestHeaders);
Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests (1)
Infrastructure\TestHelpers.cs (1)
25httpContext.Request.Host = new HostString("localhost");
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (84)
Infrastructure\TestHelpers.cs (1)
27httpContext.Request.Host = new HostString("localhost");
JsonTranscodingRouteAdapterTests.cs (16)
39httpContext.Request.RouteValues = new RouteValueDictionary 47Assert.Equal("shelves/first/books/second", httpContext.Request.RouteValues["book.name"]); 139httpContext.Request.RouteValues = new RouteValueDictionary 146Assert.Equal("a/my/value/b", httpContext.Request.RouteValues["x.y.z"]); 158httpContext.Request.RouteValues = new RouteValueDictionary 165Assert.Equal("a/my/value/b", httpContext.Request.RouteValues["x.y.z"]); 177httpContext.Request.RouteValues = new RouteValueDictionary 184Assert.Equal("c/value", httpContext.Request.RouteValues["b"]); 196httpContext.Request.RouteValues = new RouteValueDictionary 203Assert.Equal("c/value/d", httpContext.Request.RouteValues["b"]); 215httpContext.Request.RouteValues = new RouteValueDictionary 222Assert.Equal("c/value", httpContext.Request.RouteValues["b"]); 252httpContext.Request.RouteValues = new RouteValueDictionary 259Assert.Equal("test/name", httpContext.Request.RouteValues["name"]); 271httpContext.Request.RouteValues = new RouteValueDictionary 278Assert.Equal("test/name/", httpContext.Request.RouteValues["name"]);
JsonTranscodingServerCallContextTests.cs (6)
40httpContext.Request.Headers.Append("TestName", "TestValue"); 41httpContext.Request.Headers.Append(":method", "GET"); 42httpContext.Request.Headers.Append("grpc-encoding", "identity"); 43httpContext.Request.Headers.Append("grpc-timeout", "1S"); 44httpContext.Request.Headers.Append("hello-bin", Convert.ToBase64String(new byte[] { 1, 2, 3 })); 64httpContext.Request.Host = new HostString("localhost");
ServerStreamingServerCallHandlerTests.cs (5)
57httpContext.Request.RouteValues["name"] = "TestName!"; 104httpContext.Request.RouteValues["name"] = "TestName!"; 146httpContext.Request.RouteValues["name"] = "TestName!"; 187httpContext.Request.RouteValues["name"] = "TestName!"; 238httpContext.Request.RouteValues["name"] = "TestName!";
UnaryServerCallHandlerTests.cs (56)
66httpContext.Request.RouteValues["name"] = "TestName!"; 67httpContext.Request.RouteValues["sub.subfield"] = "Subfield!"; 109httpContext.Request.RouteValues["name"] = name; 143httpContext.Request.RouteValues["name"] = "Doesn't matter"; 201httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest 205httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 210httpContext.Request.ContentType = "application/json"; 239httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest.Types.SubMessage 243httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 249httpContext.Request.ContentType = "application/json"; 289httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 290httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 296httpContext.Request.ContentType = "application/json"; 339httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 340httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 346httpContext.Request.ContentType = "application/json"; 389httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 390httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 396httpContext.Request.ContentType = "application/json"; 439httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 440httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 446httpContext.Request.ContentType = "application/json"; 489httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 490httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 496httpContext.Request.ContentType = "application/json"; 524httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 552httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 583httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 619httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 650httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 676httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 703httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 739httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 740httpContext.Request.ContentType = "application/json"; 777httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 778httpContext.Request.ContentType = "application/json"; 806httpContext.Request.Body = new MemoryStream("{}"u8.ToArray()); 807httpContext.Request.ContentType = contentType; 1140httpContext.Request.ContentType = "application/xml"; 1141httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1184httpContext.Request.ContentType = "application/octet-stream"; 1191httpContext.Request.Body = new MemoryStream(requestContent); 1194httpContext.Request.ContentLength = requestSize; 1227httpContext.Request.ContentType = "application/json"; 1228httpContext.Request.Body = new MemoryStream("null"u8.ToArray()); 1262httpContext.Request.ContentType = "application/json"; 1263httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson)); 1324httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1325httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1492httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1520httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1664httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1723httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson)); 1724httpContext.Request.ContentType = "application/json"; 1759httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1793httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues>
Microsoft.AspNetCore.HeaderPropagation.Tests (8)
HeaderPropagationMiddlewareTest.cs (8)
40Context.Request.Headers.Add("in", "test"); 67Context.Request.Headers.Add("in", "test"); 82Context.Request.Headers.Add("in", "test"); 83Context.Request.Headers.Add("another", "test2"); 102Context.Request.Headers.Add("in", headerValue); 128Context.Request.Headers.Add("in", "value"); 146Context.Request.Headers.Add("in", "no"); 161Context.Request.Headers.Add("in", "no");
Microsoft.AspNetCore.Hosting.Tests (24)
HostingApplicationDiagnosticsTests.cs (14)
190c.Request.Protocol = "1.1"; 191c.Request.Scheme = "http"; 192c.Request.Method = "POST"; 193c.Request.Host = new HostString("localhost"); 194c.Request.Path = "/hello"; 195c.Request.ContentType = "text/plain"; 196c.Request.ContentLength = 1024; 794c.Request.Protocol = "1.1"; 795c.Request.Scheme = "http"; 796c.Request.Method = "POST"; 797c.Request.Host = new HostString("localhost"); 798c.Request.Path = "/hello"; 799c.Request.ContentType = "text/plain"; 800c.Request.ContentLength = 1024;
HostingMetricsTests.cs (4)
36httpContext.Request.Protocol = HttpProtocol.Http11; 48httpContext.Request.Protocol = HttpProtocol.Http2; 63httpContext.Request.Protocol = HttpProtocol.Http3; 134httpContext.Request.Protocol = HttpProtocol.Http11;
Internal\HostingEventSourceTests.cs (6)
77context.Request.Method = "GET"; 78context.Request.Path = "/Home/Index"; 88context.Request.Method = "POST"; 89context.Request.Path = "/"; 113hostingEventSource.RequestStart(httpContext.Request.Method, httpContext.Request.Path);
Microsoft.AspNetCore.Http.Abstractions.Tests (1)
CookieBuilderTests.cs (1)
22context.Request.IsHttps = requestIsHttps;
Microsoft.AspNetCore.Http.Connections.Tests (118)
HttpConnectionDispatcherTests.cs (117)
66context.Request.Path = "/foo"; 67context.Request.Method = "POST"; 90context.Request.Path = "/foo"; 91context.Request.Method = "POST"; 93context.Request.QueryString = new QueryString("?negotiateVersion=1"); 116context.Request.Path = "/foo"; 117context.Request.Method = "POST"; 119context.Request.QueryString = new QueryString("?negotiateVersion=1"); 124context.Request.QueryString = context.Request.QueryString.Add("id", connectionToken); 153context.Request.Path = "/foo"; 154context.Request.Method = "POST"; 156context.Request.QueryString = new QueryString("?negotiateVersion=Invalid"); 181context.Request.Path = "/foo"; 182context.Request.Method = "POST"; 184context.Request.QueryString = new QueryString(""); 220context.Request.Body = requestBody; 226context.Request.Path = "/foo"; 227context.Request.Method = "POST"; 232context.Request.Query = qs; 268context.Request.Path = "/foo"; 269context.Request.Method = "POST"; 271context.Request.QueryString = new QueryString("?negotiateVersion=1"); 306context.Request.Path = "/foo"; 307context.Request.Method = "GET"; 312context.Request.Query = qs; 348context.Request.Path = "/foo"; 349context.Request.Method = "POST"; 354context.Request.Query = qs; 386context.Request.Path = "/foo"; 387context.Request.Method = "POST"; 392context.Request.Query = qs; 425context.Request.Path = "/foo"; 426context.Request.Method = "POST"; 431context.Request.Query = qs; 465context.Request.Path = "/foo"; 466context.Request.Method = "GET"; 471context.Request.Query = qs; 528context.Request.Path = "/foo"; 529context.Request.Method = "GET"; 534context.Request.Query = qs; 590context.Request.Body = requestBody; 596context.Request.Path = "/foo"; 597context.Request.Method = "POST"; 602context.Request.Query = qs; 654context.Request.Body = requestBody; 659context.Request.Path = "/foo"; 660context.Request.Method = "POST"; 665context.Request.Query = qs; 755context.Request.Body = requestBody; 763context.Request.Path = "/foo"; 764context.Request.Method = "GET"; 770context.Request.Query = qs; 771context.Request.Headers["header1"] = "h1"; 772context.Request.Headers["header2"] = "h2"; 773context.Request.Headers["header3"] = "h3"; 858context.Request.Path = "/foo"; 859context.Request.Method = "GET"; 860context.Request.QueryString = new QueryString("?negotiateVersion=1"); 899context.Request.Body = mockStream.Object; 905context.Request.Path = "/foo"; 906context.Request.Method = "POST"; 911context.Request.Query = qs; 934context.Request.Path = "/foo"; 935context.Request.Method = "POST"; 936context.Request.QueryString = new QueryString("?negotiateVersion=1"); 1839context.Request.Path = "/foo"; 1840context.Request.Method = "GET"; 1846context.Request.Query = qs; 1891context.Request.Path = "/foo"; 1892context.Request.Method = "GET"; 1898context.Request.Query = qs; 2034deleteContext.Request.Path = "/foo"; 2035deleteContext.Request.QueryString = new QueryString($"?id={connection.ConnectionToken}"); 2036deleteContext.Request.Method = "DELETE"; 2077deleteContext.Request.Path = "/foo"; 2078deleteContext.Request.QueryString = new QueryString($"?id={connection.ConnectionToken}"); 2079deleteContext.Request.Method = "DELETE"; 2127deleteContext.Request.Path = "/foo"; 2128deleteContext.Request.QueryString = new QueryString($"?id={connection.ConnectionToken}"); 2129deleteContext.Request.Method = "DELETE"; 2182deleteContext.Request.Path = "/foo"; 2183deleteContext.Request.QueryString = new QueryString($"?id={connection.ConnectionId}"); 2184deleteContext.Request.Method = "DELETE"; 2270context.Request.Path = "/foo"; 2271context.Request.Method = "POST"; 2273context.Request.QueryString = new QueryString("?negotiateVersion=1"); 2296context.Request.Path = "/foo"; 2297context.Request.Method = "POST"; 2299context.Request.QueryString = new QueryString("?negotiateVersion=1&UseStatefulReconnect=true"); 2325context.Request.Path = "/foo"; 2326context.Request.Method = "POST"; 2328context.Request.QueryString = new QueryString("?negotiateVersion=1"); 2354context.Request.Path = "/foo"; 2355context.Request.Method = "POST"; 2357context.Request.QueryString = new QueryString("?negotiateVersion=1&UseStatefulReconnect=true"); 2566context.Request.Body = requestBody; 2568context.Request.Path = "/foo"; 2569context.Request.Method = "POST"; 2574context.Request.Query = qs; 2626context.Request.Body = requestBody; 2628context.Request.Path = "/foo"; 2629context.Request.Method = "POST"; 2634context.Request.Query = qs; 2683context.Request.Body = requestBody; 2685context.Request.Path = "/foo"; 2686context.Request.Method = "POST"; 2691context.Request.Query = qs; 2788deleteContext.Request.Path = "/foo"; 2789deleteContext.Request.QueryString = new QueryString($"?id={connection.ConnectionId}"); 2790deleteContext.Request.Method = "DELETE"; 3697context.Request.Path = "/foo"; 3698context.Request.Method = "GET"; 3703context.Request.Query = qs; 3734context.Request.Path = path; 3735context.Request.Method = "GET"; 3744context.Request.Query = qs;
WebSocketsTests.cs (1)
374context.Request.Headers.Add(HeaderNames.WebSocketSubProtocols, providedSubProtocols.ToArray());
Microsoft.AspNetCore.Http.Extensions.Tests (131)
HeaderDictionaryTypeExtensionsTest.cs (46)
14context.Request.Headers.ContentType = "text/plain"; 16var result = context.Request.GetTypedHeaders().Get<MediaTypeHeaderValue>(HeaderNames.ContentType); 27var result = context.Request.GetTypedHeaders().Get<MediaTypeHeaderValue>(HeaderNames.ContentType); 36context.Request.Headers.ContentType = "invalid"; 38var result = context.Request.GetTypedHeaders().Get<MediaTypeHeaderValue>(HeaderNames.ContentType); 47context.Request.Headers.CacheControl = "max-age=604800"; 49var result = context.Request.GetTypedHeaders().Get<CacheControlHeaderValue>(HeaderNames.CacheControl); 59context.Request.Headers.ContentDisposition = "form-data; name=\"fieldName\""; 61var result = context.Request.GetTypedHeaders().Get<ContentDispositionHeaderValue>(HeaderNames.ContentDisposition); 71context.Request.Headers.IfRange = "\"etag1\""; 73var result = context.Request.GetTypedHeaders().Get<RangeConditionHeaderValue>(HeaderNames.IfRange); 83context.Request.Headers.Range = "bytes=0-499"; 85var result = context.Request.GetTypedHeaders().Get<RangeHeaderValue>(HeaderNames.Range); 95context.Request.Headers.ETag = "\"123\""; 97var result = context.Request.GetTypedHeaders().Get<EntityTagHeaderValue>(HeaderNames.ETag); 108context.Request.Headers.ETag = expected.ToString("r"); 110var result = context.Request.GetTypedHeaders().Get<DateTimeOffset?>(HeaderNames.ETag); 119context.Request.Headers.ETag = $"{int.MaxValue + 1L}"; 121var result = context.Request.GetTypedHeaders().Get<long?>(HeaderNames.ETag); 130context.Request.Headers["custom"] = "valid"; 132var result = context.Request.GetTypedHeaders().Get<TestHeaderValue>("custom"); 140context.Request.Headers["custom"] = "invalid"; 142var result = context.Request.GetTypedHeaders().Get<TestHeaderValue>("custom"); 151var result = context.Request.GetTypedHeaders().Get<TestHeaderValue>("custom"); 159context.Request.Headers["custom"] = "valid"; 161Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().Get<object>("custom")); 168context.Request.Headers.Accept = "text/plain; q=0.9, text/other, */*"; 170var result = context.Request.GetTypedHeaders().GetList<MediaTypeHeaderValue>(HeaderNames.Accept); 185var result = context.Request.GetTypedHeaders().GetList<MediaTypeHeaderValue>(HeaderNames.Accept); 194context.Request.Headers.Accept = "invalid"; 196var result = context.Request.GetTypedHeaders().GetList<MediaTypeHeaderValue>(HeaderNames.Accept); 205context.Request.Headers.Accept = "text/plain; q=0.5, text/html; q=0.8"; 207var result = context.Request.GetTypedHeaders().GetList<StringWithQualityHeaderValue>(HeaderNames.Accept); 217context.Request.Headers.Cookie = "cookie1=a,cookie2=b"; 219var result = context.Request.GetTypedHeaders().GetList<CookieHeaderValue>(HeaderNames.Cookie); 229context.Request.Headers.ETag = "\"123\",\"456\""; 231var result = context.Request.GetTypedHeaders().GetList<EntityTagHeaderValue>(HeaderNames.ETag); 241context.Request.Headers.SetCookie = "cookie1=a,cookie2=b"; 243var result = context.Request.GetTypedHeaders().GetList<SetCookieHeaderValue>(HeaderNames.SetCookie); 253context.Request.Headers["custom"] = "valid"; 255var results = context.Request.GetTypedHeaders().GetList<TestHeaderValue>("custom"); 264context.Request.Headers["custom"] = "invalid"; 266var results = context.Request.GetTypedHeaders().GetList<TestHeaderValue>("custom"); 275var results = context.Request.GetTypedHeaders().GetList<TestHeaderValue>("custom"); 283context.Request.Headers["custom"] = "valid"; 285Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().GetList<object>("custom"));
HttpRequestJsonExtensionsTests.cs (39)
28var request = new DefaultHttpContext().Request; 39context.Request.ContentType = "text/json"; 42var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync<int>()); 54context.Request.ContentType = "application/json"; 57var ex = await Assert.ThrowsAsync<JsonException>(async () => await context.Request.ReadFromJsonAsync<int>()); 69context.Request.ContentType = "application/json"; 70context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 73var result = await context.Request.ReadFromJsonAsync<int>(); 84context.Request.ContentType = "application/json"; 85context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 91var result = await context.Request.ReadFromJsonAsync<List<int>>(options); 105context.Request.ContentType = "application/json; charset=utf-8"; 106context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2]")); 109var result = await context.Request.ReadFromJsonAsync<List<int>>(); 123context.Request.ContentType = "application/json; charset=utf-16"; 124context.Request.Body = new MemoryStream(Encoding.Unicode.GetBytes(@"{""name"": ""激光這兩個字是甚麼意思""}")); 127var result = await context.Request.ReadFromJsonAsync<Dictionary<string, string>>(); 138context.Request.ContentType = "application /json"; 139context.Request.Body = new TestStream(); 144var readTask = context.Request.ReadFromJsonAsync<List<int>>(cts.Token); 158context.Request.ContentType = "application/json; charset=invalid"; 161var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync<object>()); 172context.Request.ContentType = "application/json"; 173context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 176var result = (int?)await context.Request.ReadFromJsonAsync(typeof(int)); 187context.Request.ContentType = "application/json; charset=utf-16"; 188context.Request.Body = new MemoryStream(Encoding.Unicode.GetBytes(@"{""name"": ""激光這兩個字是甚麼意思""}")); 191var result = (Dictionary<string, string>?)await context.Request.ReadFromJsonAsync(typeof(Dictionary<string, string>)); 202context.Request.ContentType = "application/json; charset=invalid"; 205var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync(typeof(object))); 216context.Request.ContentType = "application/json"; 217context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 223var result = (List<int>?)await context.Request.ReadFromJsonAsync(typeof(List<int>), options); 237context.Request.ContentType = "application/json"; 238context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 245var result = (List<int>?)await context.Request.ReadFromJsonAsync(options.GetTypeInfo(typeof(List<int>))); 259context.Request.ContentType = "application/json"; 260context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 268var result = await context.Request.ReadFromJsonAsync(typeInfo);
ProblemDetailsDefaultWriterTest.cs (1)
686context.Request.Headers.Accept = contentType;
RequestDelegateFactoryTests.cs (35)
251httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 255httpContext.Request.RouteValues = new() 582httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 604httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 628httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 633httpContext.Request.Headers["Custom"] = new(new[] { "4", "5", "6" }); 635httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 663httpContext.Request.Form = new FormCollection(null); 692httpContext.Request.Headers.Referer = "https://example.org"; 753httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues>() 852httpContext.Request.Body = stream; 854httpContext.Request.Headers["Content-Type"] = "application/json"; 855httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 887httpContext.Request.Headers["Content-Type"] = "application/json"; 888httpContext.Request.Headers["Content-Length"] = "0"; 1274Assert.Equal(httpContext.Request, httpRequestArgument); 1564httpContext.Request.RouteValues[paramName] = routeParam; 1667httpContext.Request.Headers.Referer = "https://example.org"; 1777httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1807httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1837httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1865httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1905httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 1934httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 1935httpContext.Request.Headers["Content-Length"] = "1"; 1936httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(exception); 1967httpContext.Request.Headers["Content-Type"] = "application/json"; 1968httpContext.Request.Headers["Content-Length"] = "1000"; 1969httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(exception); 2160httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 2197httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 2871httpContext.Request.Body = stream; 2873httpContext.Request.Headers["Content-Type"] = "application/json"; 2874httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 3101httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues>
RequestDelegateFactoryTests.FormMapping.cs (8)
32httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 79httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 127httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 160httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 183httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 213httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 252httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues> 297httpContext.Request.Form = new FormCollection(new() { { "Description", "A test file" } }, formFiles);
UriHelperTests.cs (2)
86var request = new DefaultHttpContext().Request; 101var request = new DefaultHttpContext().Request;
Microsoft.AspNetCore.Http.Results.Tests (9)
CreatedAtRouteOfTResultTests.cs (1)
182httpContext.Request.PathBase = new PathString("");
CreatedAtRouteResultTests.cs (1)
128httpContext.Request.PathBase = new PathString("");
CreatedOfTResultTests.cs (1)
179httpContext.Request.PathBase = new PathString("");
CreatedResultTests.cs (1)
116httpContext.Request.PathBase = new PathString("");
EmptyResultTests.cs (1)
40httpContext.Request.PathBase = new PathString("");
LocalRedirectResultTests.cs (1)
132httpContext.Request.PathBase = new PathString(appRoot);
NotFoundOfTResultTests.cs (1)
142httpContext.Request.PathBase = new PathString("");
NotFoundResultTests.cs (1)
91httpContext.Request.PathBase = new PathString("");
src\Shared\ResultsTests\RedirectResultTestBase.cs (1)
74httpContext.Request.PathBase = new PathString(appRoot);
Microsoft.AspNetCore.Http.Tests (118)
ApplicationBuilderTests.cs (7)
90httpContext.Request.Protocol = "HTTP/2"; 91httpContext.Request.Scheme = "https"; 92httpContext.Request.Method = "GET"; 93httpContext.Request.Host = new HostString("localhost:5000"); 94httpContext.Request.Path = "/path"; 95httpContext.Request.PathBase = "/pathbase"; 96httpContext.Request.QueryString = new QueryString("?query=true");
DefaultHttpContextTests.cs (3)
298context.Request.Method = "GET"; 308context.Request.Protocol = "HTTP/2"; 318context.Request.ContentType = "application/json";
Features\FormFeatureTests.cs (71)
17context.Request.ContentType = MultipartContentType; 18context.Request.ContentLength = 0; 20var formFeature = new FormFeature(context.Request, new FormOptions()); 23var formCollection = await context.Request.ReadFormAsync(); 32context.Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; 39context.Request.Body = new NonSeekableReadStream(formContent); 41var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 55context.Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; 56context.Request.Body = new NonSeekableReadStream(formContent); 58IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 61var formCollection = await context.Request.ReadFormAsync(); 65Assert.Equal(bufferRequest, context.Request.Body.CanSeek); 68Assert.Equal(0, context.Request.Body.Position); 90context.Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; 100IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 103var formCollection = await context.Request.ReadFormAsync(); 205context.Request.ContentType = MultipartContentType; 206context.Request.Body = new NonSeekableReadStream(formContent); 208IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 211var formCollection = context.Request.Form; 220Assert.Same(formCollection, await context.Request.ReadFormAsync()); 240context.Request.ContentType = MultipartContentType; 241context.Request.Body = new NonSeekableReadStream(formContent); 243IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 246var formCollection = context.Request.Form; 255Assert.Same(formCollection, await context.Request.ReadFormAsync()); 277context.Request.ContentType = MultipartContentType; 278context.Request.Body = new NonSeekableReadStream(formContent); 280IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 283var formCollection = await context.Request.ReadFormAsync(); 292Assert.Same(formCollection, context.Request.Form); 325context.Request.ContentType = MultipartContentTypeWithSpecialCharacters; 326context.Request.Body = new NonSeekableReadStream(formContent); 328IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 331var formCollection = context.Request.Form; 340Assert.Same(formCollection, await context.Request.ReadFormAsync()); 362context.Request.ContentType = MultipartContentType; 363context.Request.Body = new NonSeekableReadStream(formContent); 365IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 368var formCollection = await context.Request.ReadFormAsync(); 377Assert.Same(formCollection, context.Request.Form); 410context.Request.ContentType = MultipartContentType; 411context.Request.Body = new NonSeekableReadStream(formContent); 413IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 416var formCollection = await context.Request.ReadFormAsync(); 425Assert.Same(formCollection, context.Request.Form); 462context.Request.ContentType = MultipartContentType; 463context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 465IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest, ValueCountLimit = 2 }); 468var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 486context.Request.ContentType = MultipartContentType; 487context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 489IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest, ValueCountLimit = 2 }); 492var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 510context.Request.ContentType = MultipartContentType; 511context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 513IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest, ValueCountLimit = 2 }); 516var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 534context.Request.ContentType = MultipartContentType; 535context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 537IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest, ValueCountLimit = 2 }); 540var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 559context.Request.ContentType = MultipartContentType; 560context.Request.Body = new NonSeekableReadStream(formContent); 562IFormFeature formFeature = new FormFeature(context.Request, new FormOptions() { BufferBody = bufferRequest }); 565var formCollection = await context.Request.ReadFormAsync(); 574Assert.Same(formCollection, context.Request.Form); 602context.Request.ContentType = MultipartContentType; 603context.Request.Body = new NonSeekableReadStream(formContent); 605IFormFeature formFeature = new FormFeature(context.Request, new FormOptions()); 608var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync());
Features\RequestBodyPipeFeatureTests.cs (4)
18context.Request.Body = expectedStream; 31context.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes("hahaha")); 36context.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes(expectedString)); 56context.Request.Body = mockStream.Object;
Internal\DefaultHttpRequestTests.cs (33)
121var request = new DefaultHttpContext().Request; 137var request = new DefaultHttpContext().Request; 166var request = new DefaultHttpContext().Request; 200var request = context.Request; 246var bodyPipe = context.Request.BodyReader; 255var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 263context.Request.Method = "GET"; 265var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 273context.Request.Protocol = "HTTP/2"; 275var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 283context.Request.ContentType = "application/json"; 285var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 293context.Request.QueryString = new QueryString("?query=true"); 295var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 303context.Request.Scheme = "http"; 304context.Request.Host = new HostString("localhost", 8080); 305context.Request.Path = "/Path"; 306context.Request.PathBase = "/PathBase"; 307context.Request.QueryString = new QueryString("?test=true"); 309var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 317context.Request.Scheme = "http"; 318context.Request.Host = new HostString("localhost"); 320var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 328context.Request.Method = "GET"; 329context.Request.Protocol = "HTTP/2"; 330context.Request.ContentType = "application/json"; 331context.Request.Scheme = "http"; 332context.Request.Host = new HostString("localhost", 8080); 333context.Request.Path = "/Path"; 334context.Request.PathBase = "/PathBase"; 335context.Request.QueryString = new QueryString("?test=true"); 337var debugText = HttpContextDebugFormatter.RequestToString(context.Request); 350return context.Request;
Microsoft.AspNetCore.HttpLogging.Tests (65)
HttpLoggingMiddlewareTests.cs (47)
260httpContext.Request.Headers["foo"] = "bar"; 278httpContext.Request.Headers["Connection"] = "keep-alive"; 280httpContext.Request.Headers["foo"] = "bar"; 298httpContext.Request.ContentType = "text/plain"; 299httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Hello World")); 329httpContext.Request.ContentType = "text/plain"; 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 357httpContext.Request.ContentType = "text/plain"; 358httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 385httpContext.Request.ContentType = "text/plain"; 386httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 421httpContext.Request.ContentType = "text/plain"; 422httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 457httpContext.Request.ContentType = "text/plain"; 458httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 482httpContext.Request.ContentType = "text/plain"; 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 508httpContext.Request.ContentType = "text/plain"; 509httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 547httpContext.Request.ContentType = contentType; 548httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 587httpContext.Request.ContentType = contentType; 588httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 626httpContext.Request.ContentType = "text/plain"; 627httpContext.Request.Body = new MemoryStream(encoding.GetBytes(expected)); 664httpContext.Request.ContentType = "text/plain; charset=" + Encoding.ASCII.WebName; 665httpContext.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes(expected)); 703httpContext.Request.ContentType = "text/plain; charset=" + Encoding.UTF32.WebName; 704httpContext.Request.Body = new MemoryStream(Encoding.UTF32.GetBytes(expected)); 1187httpContext.Request.Headers.Remove(HeaderNames.ContentType); 1248httpContext.Request.Protocol = "HTTP/1.1"; 1249httpContext.Request.Method = "GET"; 1250httpContext.Request.Scheme = "http"; 1251httpContext.Request.Path = "/"; 1252httpContext.Request.Headers.Connection = HeaderNames.Upgrade; 1253httpContext.Request.Headers.Upgrade = "websocket"; 1523httpContext.Request.ContentType = null; 1524httpContext.Request.Body = Stream.Null; 1956httpContext.Request.Protocol = "HTTP/1.0"; 1957httpContext.Request.Method = "GET"; 1958httpContext.Request.Scheme = "http"; 1959httpContext.Request.Path = new PathString("/foo"); 1960httpContext.Request.PathBase = new PathString("/foo"); 1961httpContext.Request.QueryString = new QueryString("?foo"); 1962httpContext.Request.Headers["Connection"] = "keep-alive"; 1963httpContext.Request.ContentType = "text/plain"; 1964httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("test"));
W3CLoggingMiddlewareTests.cs (18)
55httpContext.Request.Protocol = "HTTP/1.0"; 56httpContext.Request.Method = "GET"; 57httpContext.Request.Path = new PathString("/foo"); 58httpContext.Request.QueryString = new QueryString("?foo"); 59httpContext.Request.Headers["Referer"] = "bar"; 82httpContext.Request.Protocol = "HTTP/1.0"; 83httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 126httpContext.Request.Protocol = "HTTP/1.0"; 127httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 128httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348"; 168httpContext.Request.Protocol = "HTTP/1.0"; 169httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 199httpContext.Request.Protocol = "HTTP/1.0"; 200httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 201httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348"; 246httpContext.Request.Protocol = "HTTP/1.0"; 247httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 248httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348";
Microsoft.AspNetCore.Mvc.Core.Test (102)
ActionConstraints\HttpMethodActionConstraintTest.cs (3)
72httpContext.Request.Method = requestedMethod; 76httpContext.Request.Headers.Add("Origin", StringValues.Empty); 77httpContext.Request.Headers.Add("Access-Control-Request-Method", accessControlMethod);
ConsumesAttributeTests.cs (4)
301httpContext.Request.ContentType = contentType; 331httpContext.Request.ContentType = contentType; 360httpContext.Request.ContentType = contentType; 423httpContext.Request.ContentType = contentType;
CreatedAtActionResultTests.cs (1)
78httpContext.Request.PathBase = new PathString("");
CreatedAtRouteResultTests.cs (1)
92httpContext.Request.PathBase = new PathString("");
CreatedResultTests.cs (1)
125httpContext.Request.PathBase = new PathString("");
FileResultHelperTest.cs (8)
248httpContext.Request.Method = HttpMethods.Get; 249var httpRequestHeaders = httpContext.Request.GetTypedHeaders(); 289httpContext.Request.Method = HttpMethods.Delete; 290var httpRequestHeaders = httpContext.Request.GetTypedHeaders(); 326httpContext.Request.Method = HttpMethods.Get; 327var httpRequestHeaders = httpContext.Request.GetTypedHeaders(); 362httpContext.Request.Method = HttpMethods.Get; 363var httpRequestHeaders = httpContext.Request.GetTypedHeaders();
Formatters\InputFormatterTest.cs (9)
35httpContext.Request.ContentType = requestContentType; 69httpContext.Request.ContentType = requestContentType; 100httpContext.Request.ContentType = requestContentType; 134httpContext.Request.ContentType = requestContentType; 165httpContext.Request.ContentType = requestContentType; 202httpContext.Request.ContentType = requestContentType; 232httpContext.Request.ContentType = requestContentType; 270httpContext.Request.ContentType = requestContentType; 299httpContext.Request.ContentType = requestContentType;
Formatters\JsonInputFormatterTestBase.cs (3)
641httpContext.Request.Body = requestStream; 642httpContext.Request.ContentType = contentType; 643httpContext.Request.ContentLength = requestStream.Length;
Formatters\JsonOutputFormatterTestBase.cs (2)
167httpContext.Request.ContentType = contentType.ToString(); 168httpContext.Request.Headers.AcceptCharset = contentType.Charset.ToString();
Formatters\TextOutputFormatterTests.cs (2)
42var httpRequest = new DefaultHttpContext().Request; 242context.Request.Headers.AcceptCharset = expectedValue;
HttpNotFoundObjectResultTest.cs (1)
58httpContext.Request.PathBase = new PathString("");
Infrastructure\ActionSelectorTest.cs (1)
1026httpContext.Request.Method = httpMethod;
Infrastructure\ObjectResultExecutorTest.cs (5)
26httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 54httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 77httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 189httpContext.Request.Headers.Accept = "application/json"; // This will not be used 215httpContext.Request.Headers.Accept = "application/xml"; // This will not be used
LocalRedirectResultTest.cs (1)
150httpContext.Request.PathBase = new PathString(appRoot);
ModelBinding\Binders\BodyModelBinderTests.cs (17)
253httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 254httpContext.Request.ContentType = "text/xyz"; 301httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 302httpContext.Request.ContentType = "application/xml"; 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 331httpContext.Request.ContentType = "application/json"; 372httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 373httpContext.Request.ContentType = "application/xml"; 401httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 402httpContext.Request.ContentType = "application/json"; 448httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 449httpContext.Request.ContentType = contentType; 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 484httpContext.Request.ContentType = contentType; 512httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data")); 513httpContext.Request.ContentType = "text/xyz"; 536httpContext.Request.ContentType = "text/xyz";
ModelBinding\FormFileValueProviderFactoryTest.cs (2)
116context.Request.ContentType = contentType; 117context.Request.Form = new FormCollection(new Dictionary<string, StringValues>(), new FormFileCollection());
ModelBinding\FormFileValueProviderTest.cs (6)
16httpContext.Request.ContentType = "multipart/form-data"; 19httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues>(), formFiles); 35httpContext.Request.ContentType = "multipart/form-data"; 38httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues>(), formFiles); 54httpContext.Request.ContentType = "multipart/form-data"; 57httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues>(), formFiles);
ModelBinding\FormValueProviderFactoryTest.cs (3)
104context.Request.ContentType = contentType; 106if (context.Request.HasFormContentType) 108context.Request.Form = new FormCollection(new Dictionary<string, StringValues>());
ModelBinding\JQueryFormValueProviderFactoryTest.cs (3)
189context.Request.ContentType = contentType; 191if (context.Request.HasFormContentType) 193context.Request.Form = new FormCollection(formValues ?? new Dictionary<string, StringValues>());
ModelBinding\JQueryQueryStringValueProviderFactoryTest.cs (1)
117context.Request.Query = new QueryCollection(queryStringValues);
ModelBinding\QueryStringValueProviderFactoryTest.cs (1)
36context.Request.Query = new QueryCollection(queryValues);
RequireHttpsAttributeTests.cs (17)
20requestContext.Request.Scheme = "https"; 71requestContext.Request.Scheme = "http"; 72requestContext.Request.Method = "GET"; 73requestContext.Request.Host = HostString.FromUriComponent(host); 77requestContext.Request.PathBase = new PathString(pathBase); 82requestContext.Request.Path = new PathString(path); 87requestContext.Request.QueryString = new QueryString(queryString); 114requestContext.Request.Scheme = "http"; 115requestContext.Request.Method = method; 134requestContext.Request.Scheme = "http"; 173requestContext.Request.Scheme = "http"; 174requestContext.Request.Method = "GET"; 175requestContext.Request.Host = HostString.FromUriComponent(uri); 176requestContext.Request.Path = PathString.FromUriComponent(uri); 177requestContext.Request.QueryString = QueryString.FromUriComponent(uri); 201requestContext.Request.Scheme = "http"; 202requestContext.Request.Method = "GET";
Routing\AttributeRouteTest.cs (1)
81httpContext.Request.Path = new PathString("/api/Store/Buy/5");
Routing\ControllerLinkGeneratorExtensionsTest.cs (1)
233httpContext.Request.RouteValues = new RouteValueDictionary(ambientValues);
Routing\PageLinkGeneratorExtensionsTest.cs (1)
203httpContext.Request.RouteValues = new RouteValueDictionary(ambientValues);
Routing\UrlHelperBaseTest.cs (3)
125context.Request.PathBase = new PathString(appRoot); 126context.Request.Host = new HostString(host); 127context.Request.Scheme = protocol;
Routing\UrlHelperTestBase.cs (3)
1152context.Request.PathBase = new PathString(appRoot); 1153context.Request.Host = new HostString(host); 1154context.Request.Scheme = protocol;
src\Shared\ResultsTests\RedirectResultTestBase.cs (1)
74httpContext.Request.PathBase = new PathString(appRoot);
Microsoft.AspNetCore.Mvc.Cors.Test (16)
CorsAuthorizationFilterTest.cs (5)
138httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, headers.Headers.Split(',')); 139httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { headers.Method }); 140httpContext.Request.Headers.Add(CorsConstants.AccessControlExposeHeaders, headers.ExposedHeaders.Split(',')); 141httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { headers.Origin }); 149httpContext.Request.Method = method;
CorsHttpMethodActionConstraintTest.cs (3)
88httpContext.Request.Method = requestedMethod; 92httpContext.Request.Headers.Add("Origin", StringValues.Empty); 95httpContext.Request.Headers.Add("Access-Control-Request-Method", accessControlMethod);
DisableCorsAuthorizationFilterTest.cs (8)
20httpContext.Request.Method = "GET"; 21httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 22httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, "PUT"); 40httpContext.Request.Method = "OPTIONS"; 41httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 61httpContext.Request.Method = preflightMethod; 62httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 63httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, "PUT");
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (24)
XmlDataContractSerializerInputFormatterTest.cs (11)
149httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: true); 150httpContext.Request.ContentType = "application/json"; 181httpContext.Request.Body = testBufferedReadStream; 213httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 214httpContext.Request.ContentType = "application/xml"; 248httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 249httpContext.Request.ContentType = "application/json"; 280httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 281httpContext.Request.ContentType = "application/xml"; 339httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 340httpContext.Request.ContentType = "application/xml";
XmlDataContractSerializerOutputFormatterTest.cs (1)
803var request = httpContext.Request;
XmlSerializerInputFormatterTest.cs (11)
54httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: true); 55httpContext.Request.ContentType = "application/json"; 91httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 92httpContext.Request.ContentType = "application/xml"; 127httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 128httpContext.Request.ContentType = "application/json"; 163httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 164httpContext.Request.ContentType = "application/xml"; 205httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 206httpContext.Request.ContentType = "application/xml"; 636httpContext.Request.Body = testBufferedReadStream;
XmlSerializerOutputFormatterTest.cs (1)
585var request = httpContext.Request;
Microsoft.AspNetCore.Mvc.IntegrationTests (1)
ModelBindingTestHelper.cs (1)
156updateRequest?.Invoke(httpContext.Request);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (21)
NewtonsoftJsonInputFormatterTest.cs (11)
41httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 42httpContext.Request.ContentType = "application/json"; 77httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 78httpContext.Request.ContentType = "application/json"; 113httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 114httpContext.Request.ContentType = "application/json"; 130Assert.False(httpContext.Request.Body.CanSeek); 505httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 506httpContext.Request.ContentType = "application/json"; 548httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 549httpContext.Request.ContentType = "application/json";
NewtonsoftJsonPatchInputFormatterTest.cs (5)
40httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 41httpContext.Request.ContentType = "application/json"; 77httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 78httpContext.Request.ContentType = "application/json"; 95Assert.False(httpContext.Request.Body.CanSeek);
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (3)
641httpContext.Request.Body = requestStream; 642httpContext.Request.ContentType = contentType; 643httpContext.Request.ContentLength = requestStream.Length;
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (2)
167httpContext.Request.ContentType = contentType.ToString(); 168httpContext.Request.Headers.AcceptCharset = contentType.Charset.ToString();
Microsoft.AspNetCore.Mvc.RazorPages.Test (3)
Infrastructure\PageBinderFactoryTest.cs (1)
795httpContext.Request.Method = httpMethod;
PageModelTest.cs (1)
1745Assert.Same(httpContext.Request, pageModel.Request);
PageTest.cs (1)
45Assert.Same(httpContext.Request, page.Request);
Microsoft.AspNetCore.Mvc.Test (1)
Routing\ActionConstraintMatcherPolicyTest.cs (1)
467httpContext.Request.Method = httpMethod;
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (11)
CookieTempDataProviderTest.cs (11)
40httpContext.Request.PathBase = "/"; 82context.Request.Headers.Cookie = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}"; 104httpContext.Request.Headers.Cookie = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}"; 126httpContext.Request.PathBase = "/"; 161httpContext.Request.PathBase = "/"; 163httpContext.Request.IsHttps = isRequestSecure; 197httpContext.Request.PathBase = pathBase; 246httpContext.Request.PathBase = requestPathBase; 276httpContext.Request.PathBase = "/"; 277httpContext.Request.Headers.Cookie = requestCookies; 316context.Request.PathBase = "/";
Microsoft.AspNetCore.OpenApi.Tests (3)
Extensions\OpenApiEndpointRouteBuilderExtensionsTests.cs (3)
59context.Request.RouteValues.Add("documentName", "v1"); 112context.Request.RouteValues.Add("documentName", "v2"); 138context.Request.QueryString = new QueryString($"?documentName={documentName}");
Microsoft.AspNetCore.RateLimiting.Tests (6)
RateLimitingMetricsTests.cs (6)
83context.Request.Method = "GET"; 142context.Request.Method = "GET"; 208context1.Request.Method = "GET"; 216context2.Request.Method = "GET"; 277context1.Request.Method = "GET"; 285context2.Request.Method = "GET";
Microsoft.AspNetCore.RequestDecompression.Microbenchmarks (1)
RequestDecompressionMiddlewareBenchmark.cs (1)
40context.Request.Headers.ContentEncoding = "gzip";
Microsoft.AspNetCore.RequestDecompression.Tests (7)
DefaultRequestDecompressionProviderTests.cs (7)
29httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncoding); 47var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 72var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 82httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncoding); 99var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 110httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncodings); 127var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding;
Microsoft.AspNetCore.ResponseCaching.Microbenchmarks (5)
ResponseCachingBenchmark.cs (5)
57context.Request.Method = HttpMethods.Get; 58context.Request.Path = "/a"; 61context.Request.Headers.CacheControl = CacheControlHeaderValue.NoCacheString; 75context.Request.Method = HttpMethods.Get; 76context.Request.Path = "/b";
Microsoft.AspNetCore.ResponseCompression.Microbenchmarks (1)
ResponseCompressionProviderBenchmark.cs (1)
51context.Request.Headers.AcceptEncoding = AcceptEncoding;
Microsoft.AspNetCore.Rewrite.Tests (17)
IISUrlRewrite\ServerVariableTests.cs (12)
138context.Request.Method = HttpMethods.Get; 139context.Request.Scheme = "http"; 140context.Request.Host = new HostString("example.com"); 141context.Request.Path = PathString.FromUriComponent("/foo"); 142context.Request.QueryString = QueryString.FromUriComponent("?bar=1"); 143context.Request.ContentLength = 10; 144context.Request.ContentType = "json"; 145context.Request.Headers.Accept = "accept"; 146context.Request.Headers.Cookie = "cookie"; 147context.Request.Headers.Referer = "referer"; 148context.Request.Headers.UserAgent = "useragent"; 149context.Request.Headers.Connection = "connection";
PatternSegments\ServerNameSegmentTests.cs (2)
21httpContext.Request.Host = new HostString(host, port); 22httpContext.Request.Path = new PathString("/foo/bar");
PatternSegments\UrlSegmentTests.cs (3)
29httpContext.Request.Scheme = scheme; 30httpContext.Request.Host = new HostString(host, port); 31httpContext.Request.Path = new PathString(path);
Microsoft.AspNetCore.Routing.Microbenchmarks (3)
EndpointRoutingBenchmarkBase.cs (2)
130context.Request.RouteValues = new RouteValueDictionary(ambientValues); 132return (context, context.Request.RouteValues);
Matching\HttpMethodPolicyJumpTableBenchmark.cs (1)
28_httpContext.Request.Method = TestHttpMethod;
Microsoft.AspNetCore.Routing.Tests (53)
Builder\GroupTest.cs (5)
46httpContext.Request.RouteValues["id"] = "42"; 78httpContext.Request.RouteValues["org"] = "dotnet"; 79httpContext.Request.RouteValues["id"] = "42"; 112httpContext.Request.RouteValues["org"] = "dotnet"; 113httpContext.Request.RouteValues["id"] = "42";
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (1)
249httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues>
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (11)
160httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 198httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues>() 202httpContext.Request.RouteValues = new(); 203httpContext.Request.RouteValues["id"] = "42"; 538httpContext.Request.RouteValues["id"] = "13"; 580httpContext.Request.Query = new QueryCollection(new Dictionary<string, StringValues> 616httpContext.Request.RouteValues["value"] = "42"; 640httpContext.Request.RouteValues["id"] = "42"; 822httpContext.Request.RouteValues["id"] = "invalid!"; 849httpContext.Request.RouteValues["id"] = "invalid!"; 897httpContext.Request.RouteValues["id"] = "2";
Constraints\HttpMethodRouteConstraintTests.cs (2)
20httpContext.Request.Method = httpMethod; 41httpContext.Request.Method = httpMethod;
LinkGeneratorTestBase.cs (1)
17httpContext.Request.RouteValues = new RouteValueDictionary(ambientValues);
Matching\AcceptsMatcherPolicyTest.cs (1)
304httpContext.Request.ContentType = contentType;
Matching\ContentEncodingNegotiationMatcherPolicyTest.cs (22)
80httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 100httpContext.Request.Headers["Accept-Encoding"] = "br"; 120httpContext.Request.Headers["Accept-Encoding"] = "br"; 140httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 160httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 180httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 199httpContext.Request.Headers["Accept-Encoding"] = "zstd"; 220httpContext.Request.Headers["Accept-Encoding"] = "zstd"; 241httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 260httpContext.Request.Headers["Accept-Encoding"] = "br, gzip"; 279httpContext.Request.Headers["Accept-Encoding"] = "identity"; 298httpContext.Request.Headers["Accept-Encoding"] = "identity"; 317httpContext.Request.Headers["Accept-Encoding"] = ""; 449httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 467httpContext.Request.Headers["Accept-Encoding"] = "br"; 485httpContext.Request.Headers["Accept-Encoding"] = "br"; 503httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 521httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 539httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 557httpContext.Request.Headers["Accept-Encoding"] = "identity"; 575httpContext.Request.Headers["Accept-Encoding"] = "identity"; 593httpContext.Request.Headers["Accept-Encoding"] = "";
Matching\HostMatcherPolicyIntegrationTestBase.cs (3)
392httpContext.Request.Host = new HostString(host); 394httpContext.Request.Path = path; 395httpContext.Request.Scheme = scheme;
Matching\HttpMethodMatcherPolicyIntegrationTestBase.cs (4)
369httpContext.Request.Method = corsPreflight ? PreflightHttpMethod : httpMethod; 370httpContext.Request.Path = path; 374httpContext.Request.Headers[HeaderNames.Origin] = "example.com"; 375httpContext.Request.Headers[HeaderNames.AccessControlRequestMethod] = httpMethod;
Matching\MatcherConformanceTest.cs (2)
17httpContext.Request.Method = "TEST"; 18httpContext.Request.Path = path;
RouterMiddlewareTest.cs (1)
27httpContext.Request.Path = "/foo/10";
Microsoft.AspNetCore.SignalR.Tests (1)
HubConnectionHandlerTests.cs (1)
5093httpContext.Request.QueryString = new QueryString($"?client={client1.Connection.ConnectionId}");
Microsoft.AspNetCore.SpaServices.Extensions.Tests (3)
SpaProxyTests.cs (3)
34context.Request.Path = path; 35context.Request.QueryString = new QueryString(queryString); 36context.Request.Method = "GET";
Microsoft.AspNetCore.StaticFiles.Tests (10)
RangeHelperTests.cs (6)
65httpContext.Request.Headers.Range = range; 68var (isRangeRequest, parsedRangeResult) = RangeHelper.ParseRange(httpContext, httpContext.Request.GetTypedHeaders(), 10, NullLogger.Instance); 82httpContext.Request.Headers.Range = range; 85var (isRangeRequest, parsedRangeResult) = RangeHelper.ParseRange(httpContext, httpContext.Request.GetTypedHeaders(), 10, NullLogger.Instance); 98httpContext.Request.Headers.Range = range.ToString(); 101var (isRangeRequest, parsedRange) = RangeHelper.ParseRange(httpContext, httpContext.Request.GetTypedHeaders(), 4, NullLogger.Instance);
StaticFileContextTest.cs (4)
47httpContext.Request.Path = new PathString("/test/foo.txt"); 75httpContext.Request.Path = new PathString("/test/foo.txt"); 104httpContext.Request.Path = new PathString("/test/bar.txt"); 129httpContext.Request.Path = new PathString("/test/foo.txt");