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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <mabaul@microsoft.com>2019-03-06 22:56:42 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2019-03-06 22:56:42 +0300
commit6034bc00c432356a31208136b871ed152eb3f8d3 (patch)
treede30596d415f97dca0ba7190c26bb6def73a9597 /mcs/class/System.Net.Http
parent835c8590ca89b59b09abc58f6ccb6fa17a1d3243 (diff)
Introducing `HttpClient.CreateDefaultHandler()`. (#13305)
* The default `HttpClient` constructor now calls a static method `CreateDefaultHandler()`; we provide a platform-specific implementation of it. * Replaced `HeaderUtils` with `PlatformHelper` and removed the `LEGACY_HTTPCLIENT` conditional. * Added a new `socketshandler.sources` file to keep the sources in one place. * Use a reflection check in the tests instead of the `LEGACY_HTTPCLIENT` conditional. * This allows us to also get rid of the `SOCKETSHTTPHANDLER` define.
Diffstat (limited to 'mcs/class/System.Net.Http')
-rw-r--r--mcs/class/System.Net.Http/HttpClient.DefaultHandler.cs10
-rw-r--r--mcs/class/System.Net.Http/Makefile5
-rw-r--r--mcs/class/System.Net.Http/MonoWebRequestHandler.cs10
-rw-r--r--mcs/class/System.Net.Http/PlatformHelper.Legacy.cs (renamed from mcs/class/System.Net.Http/HeaderUtils.Legacy.cs)9
-rw-r--r--mcs/class/System.Net.Http/PlatformHelper.SocketsHandler.cs (renamed from mcs/class/System.Net.Http/HeaderUtils.SocketsHandler.cs)9
-rw-r--r--mcs/class/System.Net.Http/System.Net.Http.csproj56
-rw-r--r--mcs/class/System.Net.Http/Test/HttpClientTestHelpers.cs18
-rw-r--r--mcs/class/System.Net.Http/UnitTests/unit-tests.sources2
-rw-r--r--mcs/class/System.Net.Http/legacy.sources2
-rw-r--r--mcs/class/System.Net.Http/socketshandler.sources20
-rw-r--r--mcs/class/System.Net.Http/unix_net_4_x_System.Net.Http.dll.sources21
11 files changed, 94 insertions, 68 deletions
diff --git a/mcs/class/System.Net.Http/HttpClient.DefaultHandler.cs b/mcs/class/System.Net.Http/HttpClient.DefaultHandler.cs
new file mode 100644
index 00000000000..676dc6db9d5
--- /dev/null
+++ b/mcs/class/System.Net.Http/HttpClient.DefaultHandler.cs
@@ -0,0 +1,10 @@
+namespace System.Net.Http
+{
+ partial class HttpClient
+ {
+ static HttpMessageHandler CreateDefaultHandler()
+ {
+ return new HttpClientHandler();
+ }
+ }
+}
diff --git a/mcs/class/System.Net.Http/Makefile b/mcs/class/System.Net.Http/Makefile
index bb225ced69b..88f80d2e8a2 100644
--- a/mcs/class/System.Net.Http/Makefile
+++ b/mcs/class/System.Net.Http/Makefile
@@ -32,11 +32,6 @@ TEST_MCS_FLAGS =
LIBRARY_WARN_AS_ERROR = yes
-ifndef SOCKETSHTTPHANDLER
-TEST_MCS_FLAGS += -d:LEGACY_HTTPCLIENT
-LIB_MCS_FLAGS += -d:LEGACY_HTTPCLIENT
-endif
-
SUBDIRS = FunctionalTests UnitTests
include ../../build/library.make
diff --git a/mcs/class/System.Net.Http/MonoWebRequestHandler.cs b/mcs/class/System.Net.Http/MonoWebRequestHandler.cs
index ba66d28cf86..b727b06b533 100644
--- a/mcs/class/System.Net.Http/MonoWebRequestHandler.cs
+++ b/mcs/class/System.Net.Http/MonoWebRequestHandler.cs
@@ -387,7 +387,7 @@ namespace System.Net.Http
values = values.Where (l => l != "chunked");
}
- var values_formated = HeaderUtils.GetSingleHeaderString (header.Key, values);
+ var values_formated = PlatformHelper.GetSingleHeaderString (header.Key, values);
if (values_formated == null)
continue;
@@ -402,11 +402,7 @@ namespace System.Net.Http
var response = new HttpResponseMessage (wr.StatusCode);
response.RequestMessage = requestMessage;
response.ReasonPhrase = wr.StatusDescription;
-#if LEGACY_HTTPCLIENT
- response.Content = new StreamContent (wr.GetResponseStream (), cancellationToken);
-#else
- response.Content = new StreamContent (wr.GetResponseStream ());
-#endif
+ response.Content = PlatformHelper.CreateStreamContent (wr.GetResponseStream (), cancellationToken);
var headers = wr.Headers;
for (int i = 0; i < headers.Count; ++i) {
@@ -414,7 +410,7 @@ namespace System.Net.Http
var value = headers.GetValues (i);
HttpHeaders item_headers;
- if (HeaderUtils.IsContentHeader (key))
+ if (PlatformHelper.IsContentHeader (key))
item_headers = response.Content.Headers;
else
item_headers = response.Headers;
diff --git a/mcs/class/System.Net.Http/HeaderUtils.Legacy.cs b/mcs/class/System.Net.Http/PlatformHelper.Legacy.cs
index f1e51e81217..668b88bd5c8 100644
--- a/mcs/class/System.Net.Http/HeaderUtils.Legacy.cs
+++ b/mcs/class/System.Net.Http/PlatformHelper.Legacy.cs
@@ -1,9 +1,11 @@
+using System.IO;
+using System.Threading;
using System.Collections.Generic;
using System.Net.Http.Headers;
namespace System.Net.Http
{
- static class HeaderUtils
+ static class PlatformHelper
{
internal static bool IsContentHeader (string name)
{
@@ -14,5 +16,10 @@ namespace System.Net.Http
{
return HttpRequestHeaders.GetSingleHeaderString (name, values);
}
+
+ internal static StreamContent CreateStreamContent (Stream stream, CancellationToken cancellationToken)
+ {
+ return new StreamContent (stream, cancellationToken);
+ }
}
}
diff --git a/mcs/class/System.Net.Http/HeaderUtils.SocketsHandler.cs b/mcs/class/System.Net.Http/PlatformHelper.SocketsHandler.cs
index 6f41de93112..dde50c0d574 100644
--- a/mcs/class/System.Net.Http/HeaderUtils.SocketsHandler.cs
+++ b/mcs/class/System.Net.Http/PlatformHelper.SocketsHandler.cs
@@ -1,9 +1,11 @@
+using System.IO;
+using System.Threading;
using System.Collections.Generic;
using System.Net.Http.Headers;
namespace System.Net.Http
{
- static class HeaderUtils
+ static class PlatformHelper
{
internal static bool IsContentHeader (string name)
{
@@ -20,6 +22,11 @@ namespace System.Net.Http
return string.Join (separator, values);
}
+
+ internal static StreamContent CreateStreamContent (Stream stream, CancellationToken cancellationToken)
+ {
+ return new StreamContent (stream);
+ }
}
}
diff --git a/mcs/class/System.Net.Http/System.Net.Http.csproj b/mcs/class/System.Net.Http/System.Net.Http.csproj
index c19ddfb4b38..9633dd3f6b6 100644
--- a/mcs/class/System.Net.Http/System.Net.Http.csproj
+++ b/mcs/class/System.Net.Http/System.Net.Http.csproj
@@ -34,47 +34,47 @@
<PropertyGroup Condition=" '$(Platform)' == 'monodroid' ">
<OutputPath>./../../class/lib/monodroid</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monodroid</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;XAMARIN_MODERN;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;XAMARIN_MODERN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch' ">
<OutputPath>./../../class/lib/monotouch</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_watch' ">
<OutputPath>./../../class/lib/monotouch_watch</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch_watch</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_tv' ">
<OutputPath>./../../class/lib/monotouch_tv</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch_tv</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;MONOTOUCH_TV;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_REMOTING;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;MONOTOUCH_TV;XAMCORE_2_0;XAMARIN_MODERN;SYSTEM_NET_HTTP;UNIFIED;__UNIFIED__</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full_interp' ">
<OutputPath>./../../class/lib/testing_aot_full_interp</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_full_interp</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_INTERP;DISABLE_COM;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_INTERP;DISABLE_COM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_hybrid' ">
<OutputPath>./../../class/lib/testing_aot_hybrid</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_hybrid</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full' ">
<OutputPath>./../../class/lib/testing_aot_full</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_full</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_REMOTING;DISABLE_COM;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_REMOTING;DISABLE_COM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'winaot' ">
<OutputPath>./../../class/lib/winaot</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-winaot</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_REMOTING;DISABLE_COM;WIN_PLATFORM;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_REMOTING;DISABLE_COM;WIN_PLATFORM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac' ">
<OutputPath>./../../class/lib/xammac</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-xammac</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac_net_4_5' ">
<OutputPath>./../../class/lib/xammac_net_4_5</OutputPath>
@@ -84,17 +84,17 @@
<PropertyGroup Condition=" '$(Platform)' == 'orbis' ">
<OutputPath>./../../class/lib/orbis</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-orbis</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;ORBIS;DISABLE_REMOTING;DISABLE_COM;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;ORBIS;DISABLE_REMOTING;DISABLE_COM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'unreal' ">
<OutputPath>./../../class/lib/unreal</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-unreal</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;MOBILE;MOBILE_DYNAMIC;NET_3_5;NET_4_0;NET_4_5;MONO;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;MOBILE;MOBILE_DYNAMIC;NET_3_5;NET_4_0;NET_4_5;MONO</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'wasm' ">
<OutputPath>./../../class/lib/wasm</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-wasm</IntermediateOutputPath>
- <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;WASM;DISABLE_REMOTING;DISABLE_COM;FEATURE_NO_BSD_SOCKETS;LEGACY_HTTPCLIENT</DefineConstants>
+ <DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;WASM;DISABLE_REMOTING;DISABLE_COM;FEATURE_NO_BSD_SOCKETS</DefineConstants>
</PropertyGroup>
<!-- @ALL_PROFILE_PROPERTIES@ -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -121,11 +121,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -185,11 +185,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -248,11 +248,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -312,11 +312,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -375,11 +375,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -441,11 +441,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
@@ -605,12 +605,12 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StreamToStreamCopy.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StringContent.cs" />
<Compile Include="..\corlib\System.Diagnostics\Debug.cs" />
- <Compile Include="HeaderUtils.SocketsHandler.cs" />
+ <Compile Include="HttpClient.DefaultHandler.cs" />
<Compile Include="HttpClientHandler.SocketsHandler.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
- <Compile Include="StreamContent.Mono.cs" />
+ <Compile Include="PlatformHelper.SocketsHandler.cs" />
<Compile Include="corefx\NetEventSource.Http.cs" />
<Compile Include="corefx\SocketsHttpHandler.Mono.cs" />
</ItemGroup>
@@ -720,12 +720,12 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StreamToStreamCopy.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StringContent.cs" />
<Compile Include="..\corlib\System.Diagnostics\Debug.cs" />
- <Compile Include="HeaderUtils.SocketsHandler.cs" />
+ <Compile Include="HttpClient.DefaultHandler.cs" />
<Compile Include="HttpClientHandler.SocketsHandler.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
- <Compile Include="StreamContent.Mono.cs" />
+ <Compile Include="PlatformHelper.SocketsHandler.cs" />
<Compile Include="corefx\NetEventSource.Http.cs" />
<Compile Include="corefx\SocketsHttpHandler.Mono.cs" />
</ItemGroup>
@@ -835,12 +835,12 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StreamToStreamCopy.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StringContent.cs" />
<Compile Include="..\corlib\System.Diagnostics\Debug.cs" />
- <Compile Include="HeaderUtils.SocketsHandler.cs" />
+ <Compile Include="HttpClient.DefaultHandler.cs" />
<Compile Include="HttpClientHandler.SocketsHandler.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
- <Compile Include="StreamContent.Mono.cs" />
+ <Compile Include="PlatformHelper.SocketsHandler.cs" />
<Compile Include="corefx\NetEventSource.Http.cs" />
<Compile Include="corefx\SocketsHttpHandler.Mono.cs" />
</ItemGroup>
@@ -850,9 +850,9 @@
</When>
<When Condition="'$(Platform)' == 'monotouch_watch'">
<ItemGroup>
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientEx.cs" />
<Compile Include="NSUrlSessionHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="RuntimeOptions.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
@@ -915,13 +915,13 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
<Compile Include="CFContentStream.cs" />
<Compile Include="CFNetworkHandler.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientEx.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
<Compile Include="NSUrlSessionHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="RuntimeOptions.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
@@ -983,13 +983,13 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
<Compile Include="CFContentStream.cs" />
<Compile Include="CFNetworkHandler.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientEx.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
<Compile Include="NSUrlSessionHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="RuntimeOptions.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
@@ -1049,11 +1049,11 @@
<ItemGroup>
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CancellationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
- <Compile Include="HeaderUtils.Legacy.cs" />
<Compile Include="HttpClientHandler.Legacy.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
<Compile Include="MonoWebRequestHandler.cs" />
+ <Compile Include="PlatformHelper.Legacy.cs" />
<Compile Include="System.Net.Http.Headers\AuthenticationHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CacheControlHeaderValue.cs" />
<Compile Include="System.Net.Http.Headers\CollectionExtensions.cs" />
diff --git a/mcs/class/System.Net.Http/Test/HttpClientTestHelpers.cs b/mcs/class/System.Net.Http/Test/HttpClientTestHelpers.cs
index 8fb31a3ebf0..72382819ab6 100644
--- a/mcs/class/System.Net.Http/Test/HttpClientTestHelpers.cs
+++ b/mcs/class/System.Net.Http/Test/HttpClientTestHelpers.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading;
using System.Reflection;
using System.Net.Http;
@@ -6,11 +7,18 @@ namespace MonoTests.System.Net.Http
{
static class HttpClientTestHelpers
{
-#if LEGACY_HTTPCLIENT
- internal static bool UsingSocketsHandler => false;
-#else
- internal static bool UsingSocketsHandler => true;
-#endif
+ static bool initialized;
+ static bool usingSocketsHandler;
+ static object syncLock;
+
+ internal static bool UsingSocketsHandler {
+ get {
+ LazyInitializer.EnsureInitialized (
+ ref usingSocketsHandler, ref initialized, ref syncLock,
+ () => typeof (HttpClient).Assembly.GetType ("System.Net.Http.SocketsHttpHandler") != null);
+ return usingSocketsHandler;
+ }
+ }
internal static bool IsSocketsHandler (HttpClientHandler handler) => UsingSocketsHandler;
diff --git a/mcs/class/System.Net.Http/UnitTests/unit-tests.sources b/mcs/class/System.Net.Http/UnitTests/unit-tests.sources
index 28d4d4d295e..c8df8d04b8f 100644
--- a/mcs/class/System.Net.Http/UnitTests/unit-tests.sources
+++ b/mcs/class/System.Net.Http/UnitTests/unit-tests.sources
@@ -3,6 +3,8 @@
../../corlib/ReferenceSources/SR.cs
../../../build/common/SR.cs
+../HttpClient.DefaultHandler.cs
+
# Common Sources
../../../../external/corefx/src/Common/src/System/NotImplemented.cs
diff --git a/mcs/class/System.Net.Http/legacy.sources b/mcs/class/System.Net.Http/legacy.sources
index 1a5047bda62..1b5be8388fe 100644
--- a/mcs/class/System.Net.Http/legacy.sources
+++ b/mcs/class/System.Net.Http/legacy.sources
@@ -3,7 +3,7 @@ HttpClientHandler.cs
HttpClientHandler.Legacy.cs
IMonoHttpClientHandler.cs
MonoWebRequestHandler.cs
-HeaderUtils.Legacy.cs
+PlatformHelper.Legacy.cs
System.Net.Http/ByteArrayContent.cs
System.Net.Http/ClientCertificateOption.cs
System.Net.Http/DelegatingHandler.cs
diff --git a/mcs/class/System.Net.Http/socketshandler.sources b/mcs/class/System.Net.Http/socketshandler.sources
new file mode 100644
index 00000000000..f638684ac7d
--- /dev/null
+++ b/mcs/class/System.Net.Http/socketshandler.sources
@@ -0,0 +1,20 @@
+Assembly/AssemblyInfo.cs
+
+PlatformHelper.SocketsHandler.cs
+HttpClient.DefaultHandler.cs
+HttpClientHandler.cs
+HttpClientHandler.SocketsHandler.cs
+IMonoHttpClientHandler.cs
+MonoWebRequestHandler.cs
+
+../corlib/System.Diagnostics/Debug.cs
+
+corefx/SocketsHttpHandler.Mono.cs
+corefx/NetEventSource.Http.cs
+
+../../../external/corefx/src/Common/src/System/Net/Http/HttpHandlerDefaults.cs
+
+../../../external/corefx/src/System.Net.Http/src/System/Net/Http/Headers/*.cs
+../../../external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/*.cs:HttpSystemProxy.cs,SystemProxyInfo.Windows.cs
+../../../external/corefx/src/System.Net.Http/src/System/Net/Http/*.cs:HttpClientHandler.*.cs,NetEventSource.Http.cs,DiagnosticsHandler.cs
+
diff --git a/mcs/class/System.Net.Http/unix_net_4_x_System.Net.Http.dll.sources b/mcs/class/System.Net.Http/unix_net_4_x_System.Net.Http.dll.sources
index 364adf69787..74f48b08660 100644
--- a/mcs/class/System.Net.Http/unix_net_4_x_System.Net.Http.dll.sources
+++ b/mcs/class/System.Net.Http/unix_net_4_x_System.Net.Http.dll.sources
@@ -1,20 +1 @@
-Assembly/AssemblyInfo.cs
-
-HeaderUtils.SocketsHandler.cs
-HttpClientHandler.cs
-HttpClientHandler.SocketsHandler.cs
-IMonoHttpClientHandler.cs
-MonoWebRequestHandler.cs
-StreamContent.Mono.cs
-
-../corlib/System.Diagnostics/Debug.cs
-
-corefx/SocketsHttpHandler.Mono.cs
-corefx/NetEventSource.Http.cs
-
-../../../external/corefx/src/Common/src/System/Net/Http/HttpHandlerDefaults.cs
-
-../../../external/corefx/src/System.Net.Http/src/System/Net/Http/Headers/*.cs
-../../../external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/*.cs:HttpSystemProxy.cs,SystemProxyInfo.Windows.cs
-../../../external/corefx/src/System.Net.Http/src/System/Net/Http/*.cs:HttpClientHandler.*.cs,NetEventSource.Http.cs,DiagnosticsHandler.cs
-
+#include socketshandler.sources