Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HttpClientHandler.SocketsHandler.Android.cs « System.Net.Http « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9b4fadc19f173f244ab75e5209078a7bf220bf93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Reflection;

namespace System.Net.Http
{
	partial class HttpClientHandler : HttpMessageHandler
	{
		static IMonoHttpClientHandler CreateDefaultHandler ()
		{
			string envvar = Environment.GetEnvironmentVariable ("XA_HTTP_CLIENT_HANDLER_TYPE")?.Trim ();
			if (envvar?.StartsWith("System.Net.Http.MonoWebRequestHandler", StringComparison.InvariantCulture) == true)
			{
				Type monoWrhType = Type.GetType (envvar, false);
				if (monoWrhType != null)
					return (IMonoHttpClientHandler) Activator.CreateInstance (monoWrhType);
			}

			// Ignore other types of handlers here (e.g. AndroidHttpHandler) to keep the old behavior
			// and always create SocketsHttpHandler for code like this if MonoWebRequestHandler was not specified:
			//
			//    var handler = new HttpClientHandler { Credentials = ... };
			//    var httpClient = new HttpClient (handler);
			//
			// AndroidHttpHandler is used only when we use the parameterless ctor of HttpClient
			return new SocketsHttpHandler (); 
		}
	}
}