Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,24 @@ internal static void AddHeaders(IEnumerable<string> headersToForward, HttpReques

foreach (var headerName in headerNames)
{
// Workaround for an issue identified by https://github.com/dotnet/systemweb-adapters/issues/228.
// 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.
// This workaround can be removed once we target .NET 7+ as Kestrel is fixed there.
var originalHeaders = originalRequest.Headers[headerName].Where(x => !string.IsNullOrEmpty(x)).ToArray();

if (originalHeaders.Length == 0)
{
continue;
}

// Workaround for an issue identified by https://github.com/dotnet/systemweb-adapters/issues/228.
// 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.
// This workaround can be removed once we target .NET 7+ as Kestrel is fixed there.
if (string.Equals(headerName, HeaderNames.Cookie, StringComparison.OrdinalIgnoreCase))
{
authRequest.Headers.Add(headerName, string.Join("; ", originalRequest.Headers[headerName].ToArray()));
authRequest.Headers.Add(headerName, string.Join("; ", originalHeaders));
continue;
}

authRequest.Headers.Add(headerName, originalRequest.Headers[headerName].ToArray());
authRequest.Headers.Add(headerName, originalHeaders);
}
}

Expand Down