in LogicAppsSampleTestFramework/TestFramework/MockHttpHost.cs [107:159]
public void Configure(IApplicationBuilder app)
{
app.UseResponseCompression();
app.Use(async (context, next) =>
{
var syncIOFeature = context.Features.Get<IHttpBodyControlFeature>();
if (syncIOFeature != null)
{
syncIOFeature.AllowSynchronousIO = true;
}
using (var request = GetHttpRequestMessage(context))
using (var responseMessage = this.Host.RequestHandler(request))
{
var response = context.Response;
response.StatusCode = (int)responseMessage.StatusCode;
var responseHeaders = responseMessage.Headers;
// Ignore the Transfer-Encoding header if it is just "chunked".
// We let the host decide about whether the response should be chunked or not.
if (responseHeaders.TransferEncodingChunked == true &&
responseHeaders.TransferEncoding.Count == 1)
{
responseHeaders.TransferEncoding.Clear();
}
foreach (var header in responseHeaders)
{
response.Headers.Append(header.Key, header.Value.ToArray());
}
if (responseMessage.Content != null)
{
var contentHeaders = responseMessage.Content.Headers;
// Copy the response content headers only after ensuring they are complete.
// We ask for Content-Length first because HttpContent lazily computes this
// and only afterwards writes the value into the content headers.
var unused = contentHeaders.ContentLength;
foreach (var header in contentHeaders)
{
response.Headers.Append(header.Key, header.Value.ToArray());
}
await responseMessage.Content.CopyToAsync(response.Body).ConfigureAwait(false);
}
}
});
}