Skip to content
Open
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
23 changes: 16 additions & 7 deletions src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,9 @@ or ObjectDisposedException
"Last-Modified"
};

static readonly List <IAndroidAuthenticationModule> authModules = new List <IAndroidAuthenticationModule> {
new AuthModuleBasic (),
new AuthModuleDigest ()
};

CookieContainer? _cookieContainer;
DecompressionMethods _decompressionMethods;
IAndroidAuthenticationModule []? authModules;

bool disposed;
bool started;
Expand Down Expand Up @@ -759,7 +755,20 @@ public int MaxAutomaticRedirections
/// </para>
/// </summary>
/// <value>The pre authentication data.</value>
public AuthenticationData? PreAuthenticationData { get; set; }
public AuthenticationData? PreAuthenticationData {
get;
set {
// Keep these constructor references in the setter so apps that never configure pre-authentication can trim the built-in modules.
if (value != null && authModules == null) {
authModules = [
new AuthModuleBasic (),
new AuthModuleDigest ()
];
Comment on lines +762 to +766
}

field = value;
}
}

/// <summary>
/// If the website requires authentication, this property will contain data about each scheme supported
Expand Down Expand Up @@ -1768,7 +1777,7 @@ void HandlePreAuthentication (HttpURLConnection httpConnection)
return;
}

var auth = data.Scheme == AuthenticationScheme.Unsupported ? data.AuthModule : authModules.Find (m => m?.Scheme == data.Scheme);
var auth = data.Scheme == AuthenticationScheme.Unsupported ? data.AuthModule : authModules?.FirstOrDefault (m => m.Scheme == data.Scheme);
if (auth == null) {
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $"Authentication module for scheme '{data.Scheme}' not found. No authentication will be performed");
Expand Down
Loading