Merge pull request #29927 from timdeschryver/docs/http-context

docs: fix feature snippet
pull/29945/head
Rick Anderson 2023-07-27 16:56:16 -10:00 committed by GitHub
commit 4b0e88e82b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -185,7 +185,7 @@ This article primarily discusses using `HttpContext` in request and response flo
The following sample logs GitHub branches when requested from the `/branch` endpoint:
[!code-csharp[](~/fundamentals/http-context/samples/6.x/HttpContextInBackgroundThread/Program.cs?highlight=26-45)]
[!code-csharp[](~/fundamentals/http-context/samples/6.x/HttpContextInBackgroundThread/Program.cs?highlight=26-46)]
The GitHub API requires two headers. The `User-Agent` header is added dynamically by the `UserAgentHeaderHandler`:

View File

@ -153,13 +153,14 @@ var app = builder.Build();
app.MapGet("/long-running-stream", async (HttpContext context) =>
{
var feature = httpContext.Features.Get<IHttpMinRequestBodyDataRateFeature>();
var feature = context.Features.Get<IHttpMinRequestBodyDataRateFeature>();
if (feature != null)
{
feature.MinDataRate = null;
}
// Read long-running stream from request body.
// await and read long-running stream from request body.
await Task.Yield();
});
app.Run();