Allow proxy middleware to abort long running connections.

This commit is contained in:
Matt Perry
2017-05-03 22:19:42 -04:00
committed by Steve Sanderson
parent 018a3e65ff
commit 54884459bd

View File

@@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
/// </summary>
internal class ConditionalProxyMiddleware
{
private const int BUFFER_SIZE = 1024;
private readonly HttpClient _httpClient;
private readonly RequestDelegate _next;
private readonly ConditionalProxyMiddlewareOptions _options;
@@ -93,7 +94,12 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
// SendAsync removes chunking from the response. This removes the header so it doesn't expect a chunked response.
context.Response.Headers.Remove("transfer-encoding");
await responseMessage.Content.CopyToAsync(context.Response.Body);
using (var responseStream = await responseMessage.Content.ReadAsStreamAsync())
{
await responseStream.CopyToAsync(context.Response.Body, BUFFER_SIZE, context.RequestAborted);
}
return true;
}
}