Skip to content

Commit

Permalink
Fixed missing Content-Type request header (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan committed Dec 9, 2021
1 parent af4a15e commit e70ca73
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -19,13 +19,13 @@ public async Task SendAsync(string destinationUri, HttpContext httpContext, Acti
RequestUri = new Uri(destinationUri)
};

CopyRequestHeaders(httpContext, request);

if (HasRequestBody(httpContext))
{
request.Content = new StreamContent(httpContext.Request.Body);
}

CopyRequestHeaders(httpContext, request);

beforeSend?.Invoke(request);

var response = await _httpClient.SendAsync(request, httpContext.RequestAborted);
Expand Down Expand Up @@ -81,7 +81,10 @@ private static void CopyRequestHeaders(HttpContext httpContext, HttpRequestMessa
continue;
}

request.Headers.TryAddWithoutValidation(name, (string)value);
if (!request.Headers.TryAddWithoutValidation(name, (string)value))
{
request.Content?.Headers.TryAddWithoutValidation(name, (string)value);
}
}
}

Expand Down

0 comments on commit e70ca73

Please sign in to comment.