Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5488445

Browse filesBrowse files
mattvperrySteveSandersonMS
authored andcommitted
Allow proxy middleware to abort long running connections.
1 parent 018a3e6 commit 5488445
Copy full SHA for 5488445

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Open diff view settings
Collapse file

‎src/Microsoft.AspNetCore.SpaServices/Webpack/ConditionalProxyMiddleware.cs‎

Copy file name to clipboardExpand all lines: src/Microsoft.AspNetCore.SpaServices/Webpack/ConditionalProxyMiddleware.cs
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
1616
/// </summary>
1717
internal class ConditionalProxyMiddleware
1818
{
19+
private const int BUFFER_SIZE = 1024;
1920
private readonly HttpClient _httpClient;
2021
private readonly RequestDelegate _next;
2122
private readonly ConditionalProxyMiddlewareOptions _options;
@@ -93,7 +94,12 @@ private async Task<bool> PerformProxyRequest(HttpContext context)
9394

9495
// SendAsync removes chunking from the response. This removes the header so it doesn't expect a chunked response.
9596
context.Response.Headers.Remove("transfer-encoding");
96-
await responseMessage.Content.CopyToAsync(context.Response.Body);
97+
98+
using (var responseStream = await responseMessage.Content.ReadAsStreamAsync())
99+
{
100+
await responseStream.CopyToAsync(context.Response.Body, BUFFER_SIZE, context.RequestAborted);
101+
}
102+
97103
return true;
98104
}
99105
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.