<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Android</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
- <PropertyGroup Condition=" '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
+ <PropertyGroup Condition=" '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
<DefineConstants>$(DefineConstants);SYSNETHTTP_NO_OPENSSL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Include="System\Net\Http\Headers\KnownHeaders.cs" />
<Compile Include="System\Net\Http\HttpBaseStream.cs" />
<Compile Include="System\Net\Http\HttpClient.cs" />
- <Compile Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetsTVOS)' != 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.cs" />
+ <Compile Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetsMacCatalyst)' != 'true' and '$(TargetsTVOS)' != 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.cs" />
<Compile Condition="'$(TargetsAndroid)' == 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.Android.cs" />
<Compile Condition="'$(TargetsiOS)' == 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.iOS.cs" />
+ <Compile Condition="'$(TargetsMacCatalyst)' == 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.MacCatalyst.cs" />
<Compile Condition="'$(TargetsTVOS)' == 'true'" Include="System\Net\Http\HttpClient.CreateDefaultHandler.tvOS.cs" />
<Compile Include="System\Net\Http\HttpClientHandler.cs" />
<Compile Include="System\Net\Http\HttpCompletionOption.cs" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Reflection;
+
+namespace System.Net.Http
+{
+ public partial class HttpClient
+ {
+ private static MethodInfo? handlerMethod;
+
+ private static HttpMessageHandler CreateDefaultHandler()
+ {
+ // Default is to use the iOS native handler
+ if (!IsNativeHandlerEnabled())
+ {
+ return new HttpClientHandler();
+ }
+
+ if (handlerMethod == null)
+ {
+ Type? runtimeOptions = Type.GetType("ObjCRuntime.RuntimeOptions, Xamarin.MacCatalyst");
+ handlerMethod = runtimeOptions!.GetMethod("GetHttpMessageHandler", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
+ }
+
+ return (HttpMessageHandler)handlerMethod!.Invoke(null, null)!;
+ }
+ }
+}