Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Foundation] Fix NSUrlSessionHandler thread issues. #1889

Closed
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
13 changes: 9 additions & 4 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace Foundation {
#endif
public partial class NSUrlSessionHandler : HttpMessageHandler
{
static readonly NSUrlSessionConfiguration configuration;
readonly Dictionary<string, string> headerSeparators = new Dictionary<string, string> {
["User-Agent"] = " ",
["Server"] = " "
Expand All @@ -64,10 +65,9 @@ public partial class NSUrlSessionHandler : HttpMessageHandler
readonly Dictionary<NSUrlSessionTask, InflightData> inflightRequests;
readonly object inflightRequestsLock = new object ();

public NSUrlSessionHandler ()
static NSUrlSessionHandler ()
{
AllowAutoRedirect = true;
var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;
configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;

// we cannot do a bitmask but we can set the minimum based on ServicePointManager.SecurityProtocol minimum
var sp = ServicePointManager.SecurityProtocol;
Expand All @@ -79,8 +79,13 @@ public NSUrlSessionHandler ()
configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_1;
else if ((sp & SecurityProtocolType.Tls12) != 0)
configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2;
}

public NSUrlSessionHandler ()
{
AllowAutoRedirect = true;

session = NSUrlSession.FromConfiguration (NSUrlSessionConfiguration.DefaultSessionConfiguration, new NSUrlSessionHandlerDelegate (this), null);
session = NSUrlSession.FromConfiguration (configuration, new NSUrlSessionHandlerDelegate (this), null);
inflightRequests = new Dictionary<NSUrlSessionTask, InflightData> ();
}

Expand Down