|
|
|
@ -9,6 +9,7 @@ using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.Extensions.Primitives; |
|
|
|
using Microsoft.Net.Http.Headers; |
|
|
|
|
|
|
|
namespace Microsoft.AspNetCore.Proxy |
|
|
|
{ |
|
|
|
@ -80,7 +81,16 @@ namespace Microsoft.AspNetCore.Proxy |
|
|
|
// Copy the request headers
|
|
|
|
foreach (var header in request.Headers) |
|
|
|
{ |
|
|
|
if (!requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()) && requestMessage.Content != null) |
|
|
|
// taken from : https://github.com/microsoft/reverse-proxy/blob/main/src/ReverseProxy/Forwarder/RequestUtilities.cs#L283
|
|
|
|
// HttpClient wrongly uses comma (",") instead of semi-colon (";") as a separator for Cookie headers.
|
|
|
|
// To mitigate this, we concatenate them manually and put them back as a single header value.
|
|
|
|
// A multi-header cookie header is invalid, but we get one because of
|
|
|
|
// https://github.com/dotnet/aspnetcore/issues/26461
|
|
|
|
if (string.Equals(header.Key, HeaderNames.Cookie, StringComparison.OrdinalIgnoreCase)) |
|
|
|
{ |
|
|
|
requestMessage.Headers.TryAddWithoutValidation(header.Key, string.Join("; ", header.Value.ToArray())); |
|
|
|
} |
|
|
|
else if (!requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()) && requestMessage.Content != null) |
|
|
|
{ |
|
|
|
requestMessage.Content?.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); |
|
|
|
} |
|
|
|
|