Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

refactored using added language feature #836

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/Microsoft.Tye.Hosting/Infrastructure/ProxyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ public static async Task ProxyRequest(this HttpContext context, HttpMessageInvok
}
else
{
using (var requestMessage = context.CreateProxyHttpRequest(destinationUri))
{
using (var responseMessage = await context.SendProxyHttpRequest(invoker, requestMessage))
{
await context.CopyProxyHttpResponse(responseMessage);
}
}
using var requestMessage = context.CreateProxyHttpRequest(destinationUri);
using var responseMessage = await context.SendProxyHttpRequest(invoker, requestMessage);

await context.CopyProxyHttpResponse(responseMessage);
}
}

Expand Down Expand Up @@ -204,10 +201,8 @@ public static async Task CopyProxyHttpResponse(this HttpContext context, HttpRes
// SendAsync removes chunking from the response. This removes the header so it doesn't expect a chunked response.
response.Headers.Remove("transfer-encoding");

await using (var responseStream = await responseMessage.Content.ReadAsStreamAsync())
{
await responseStream.CopyToAsync(response.Body, StreamCopyBufferSize, context.RequestAborted);
}
await using var responseStream = await responseMessage.Content.ReadAsStreamAsync();
await responseStream.CopyToAsync(response.Body, StreamCopyBufferSize, context.RequestAborted);
}
}
}