-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add response / request streaming test
- Loading branch information
Showing
4 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Handlers/EchoBodyHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.Features; | ||
|
||
namespace NetCoreServer | ||
{ | ||
public class EchoBodyHandler | ||
{ | ||
public static async Task InvokeAsync(HttpContext context) | ||
{ | ||
context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null; | ||
|
||
// Report back original request method verb. | ||
context.Response.Headers["X-HttpRequest-Method"] = context.Request.Method; | ||
|
||
// Report back original entity-body related request headers. | ||
string contentLength = context.Request.Headers["Content-Length"]; | ||
if (!string.IsNullOrEmpty(contentLength)) | ||
{ | ||
context.Response.Headers["X-HttpRequest-Headers-ContentLength"] = contentLength; | ||
} | ||
|
||
string transferEncoding = context.Request.Headers["Transfer-Encoding"]; | ||
if (!string.IsNullOrEmpty(transferEncoding)) | ||
{ | ||
context.Response.Headers["X-HttpRequest-Headers-TransferEncoding"] = transferEncoding; | ||
} | ||
|
||
context.Response.StatusCode = 200; | ||
context.Response.ContentType = context.Request.ContentType; | ||
await context.Request.Body.CopyToAsync(context.Response.Body); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters