Skip to content

Commit

Permalink
Avoid ReasonPhrase overhead when using default values (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Feb 16, 2021
1 parent 0a584dd commit 3d5fb29
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ReverseProxy/Service/Proxy/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -437,7 +438,12 @@ private async Task HandleRequestFailureAsync(HttpContext context, StreamCopyHttp
private static Task CopyResponseStatusAndHeadersAsync(HttpResponseMessage source, HttpContext context, HttpTransformer transformer)
{
context.Response.StatusCode = (int)source.StatusCode;
context.Features.Get<IHttpResponseFeature>().ReasonPhrase = source.ReasonPhrase;

// Don't explicitly set the field if the default reason phrase is used
if (source.ReasonPhrase != ReasonPhrases.GetReasonPhrase((int)source.StatusCode))
{
context.Features.Get<IHttpResponseFeature>().ReasonPhrase = source.ReasonPhrase;
}

// Copies headers
return transformer.TransformResponseAsync(context, source);
Expand Down

0 comments on commit 3d5fb29

Please sign in to comment.