Skip to content
Merged
Changes from all commits
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
11 changes: 7 additions & 4 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,16 @@ void DidReceiveResponseImpl (NSUrlSession session, NSUrlSessionDataTask dataTask
httpResponse.RequestMessage.RequestUri = absoluteUri;

foreach (var v in urlResponse.AllHeaderFields) {
var key = v.Key?.ToString ();
var value = v.Value?.ToString ();

// NB: Cocoa trolling us so hard by giving us back dummy dictionary entries
if (v.Key is null || v.Value is null) continue;
if (key is null || value is null) continue;
// NSUrlSession tries to be smart with cookies, we will not use the raw value but the ones provided by the cookie storage
if (v.Key.ToString () == SetCookie) continue;
if (key == SetCookie) continue;

httpResponse.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ());
httpResponse.Content.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ());
httpResponse.Headers.TryAddWithoutValidation (key, value);
httpResponse.Content.Headers.TryAddWithoutValidation (key, value);
}

// it might be confusing that we are not using the managed CookieStore here, this is ONLY for those cookies that have been retrieved from
Expand Down
Loading