Since HttpClientHandler on mobile can support both the underlying native handler and SocketsHttpHandler, it doesn't make sense to always throw PNSE on some methods due to only the native handler not supporting them.
Fixes https://github.com/dotnet/runtime/issues/55986
Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
public HttpClientHandler() { }
public bool AllowAutoRedirect { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public bool CheckCertificateRevocationList { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Net.Http.ClientCertificateOption ClientCertificateOptions { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.ICredentials? Credentials { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public static System.Func<System.Net.Http.HttpRequestMessage, System.Security.Cryptography.X509Certificates.X509Certificate2?, System.Security.Cryptography.X509Certificates.X509Chain?, System.Net.Security.SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator { get { throw null; } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Net.ICredentials? DefaultProxyCredentials { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public int MaxAutomaticRedirections { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public int MaxConnectionsPerServer { get { throw null; } set { } }
public long MaxRequestContentBufferSize { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public int MaxResponseHeadersLength { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public bool PreAuthenticate { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Collections.Generic.IDictionary<string, object?> Properties { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Net.IWebProxy? Proxy { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Func<System.Net.Http.HttpRequestMessage, System.Security.Cryptography.X509Certificates.X509Certificate2?, System.Security.Cryptography.X509Certificates.X509Chain?, System.Net.Security.SslPolicyErrors, bool>? ServerCertificateCustomValidationCallback { get { throw null; } set { } }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public System.Security.Authentication.SslProtocols SslProtocols { get { throw null; } set { } }
public virtual bool SupportsAutomaticDecompression { get { throw null; } }
public virtual bool SupportsProxy { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool UseDefaultCredentials { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public bool UseProxy { get { throw null; } set { } }
protected override void Dispose(bool disposing) { }
//
<property name="Target">M:System.Net.Http.HttpClientHandler.SetMaxAutomaticRedirections(System.Int32)</property>
<property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
</attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetCheckCertificateRevocationList()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetCheckCertificateRevocationList(System.Boolean)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetClientCertificateOptions()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetClientCertificateOptions(System.Net.Http.ClientCertificateOption)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetClientCertificates()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetDefaultProxyCredentials()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetDefaultProxyCredentials(System.Net.ICredentials)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetMaxConnectionsPerServer()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetMaxConnectionsPerServer(System.Int32)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetMaxResponseHeadersLength()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetMaxResponseHeadersLength(System.Int32)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetProperties()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetSupportsAutomaticDecompression()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetSupportsProxy()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetSupportsRedirectConfiguration()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.GetSslProtocols()</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
+ <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
+ <argument>ILLink</argument>
+ <argument>IL2035</argument>
+ <property name="Scope">member</property>
+ <property name="Target">M:System.Net.Http.HttpClientHandler.SetSslProtocols(System.Security.Authentication.SslProtocols)</property>
+ <property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
+ </attribute>
</assembly>
</linker>
<Compile Include="System\Net\Http\HttpClient.cs" />
<Compile Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsTVOS)' == 'true'"
Include="System\Net\Http\HttpClientHandler.AnyMobile.cs" />
- <Compile Condition="'$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsTVOS)' == 'true'"
- Include="System\Net\Http\HttpClientHandler.Apple.cs" />
<Compile Condition="'$(TargetsiOS)' == 'true'" Include="System\Net\Http\HttpClientHandler.iOS.cs" />
<Compile Condition="'$(TargetsMacCatalyst)' == 'true'" Include="System\Net\Http\HttpClientHandler.MacCatalyst.cs" />
<Compile Condition="'$(TargetsTVOS)' == 'true'" Include="System\Net\Http\HttpClientHandler.tvOS.cs" />
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Net.Security;
using System.Reflection;
using System.Runtime.Versioning;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
namespace System.Net.Http
{
private const string NativeHandlerType = "Xamarin.Android.Net.AndroidMessageHandler";
private const string AssemblyName = "Mono.Android";
- public virtual bool SupportsAutomaticDecompression => true;
- public virtual bool SupportsProxy => true;
- public virtual bool SupportsRedirectConfiguration => true;
+ [DynamicDependency("get_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private ICredentials? GetDefaultProxyCredentials() => (ICredentials?)InvokeNativeHandlerMethod("get_DefaultProxyCredentials");
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public DecompressionMethods AutomaticDecompression
- {
- get
- {
- if (IsNativeHandlerEnabled)
- {
- return GetAutomaticDecompression();
- }
- else
- {
- return _socketHandler!.AutomaticDecompression;
- }
- }
- set
- {
- if (IsNativeHandlerEnabled)
- {
- SetAutomaticDecompression(value);
- }
- else
- {
- _socketHandler!.AutomaticDecompression = value;
- }
- }
- }
+ [DynamicDependency("set_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private void SetDefaultProxyCredentials(ICredentials? value) => InvokeNativeHandlerMethod("set_DefaultProxyCredentials", value);
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public bool UseProxy
- {
- get
- {
- if (IsNativeHandlerEnabled)
- {
- return GetUseProxy();
- }
- else
- {
- return _socketHandler!.UseProxy;
- }
- }
- set
- {
- if (IsNativeHandlerEnabled)
- {
- SetUseProxy(value);
- }
- else
- {
- _socketHandler!.UseProxy = value;
- }
- }
- }
+ [DynamicDependency("get_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private int GetMaxConnectionsPerServer() => (int)InvokeNativeHandlerMethod("get_MaxConnectionsPerServer");
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public IWebProxy? Proxy
- {
- get
- {
- if (IsNativeHandlerEnabled)
- {
- return GetProxy();
- }
- else
- {
- return _socketHandler!.Proxy;
- }
- }
- set
- {
- if (IsNativeHandlerEnabled)
- {
- SetProxy(value!);
- }
- else
- {
- _socketHandler!.Proxy = value;
- }
- }
- }
+ [DynamicDependency("set_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private void SetMaxConnectionsPerServer(int value) => InvokeNativeHandlerMethod("set_MaxConnectionsPerServer", value);
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public bool PreAuthenticate
- {
- get
- {
- if (IsNativeHandlerEnabled)
- {
- return GetPreAuthenticate();
- }
- else
- {
- return _socketHandler!.PreAuthenticate;
- }
- }
- set
- {
- if (IsNativeHandlerEnabled)
- {
- SetPreAuthenticate(value);
- }
- else
- {
- _socketHandler!.PreAuthenticate = value;
- }
- }
- }
+ [DynamicDependency("get_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private int GetMaxResponseHeadersLength() => (int)InvokeNativeHandlerMethod("get_MaxResponseHeadersLength");
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public int MaxAutomaticRedirections
- {
- get
- {
- if (IsNativeHandlerEnabled)
- {
- return GetMaxAutomaticRedirections();
- }
- else
- {
- return _socketHandler!.MaxAutomaticRedirections;
- }
- }
- set
- {
- if (IsNativeHandlerEnabled)
- {
- SetMaxAutomaticRedirections(value);
- }
- else
- {
- _socketHandler!.MaxAutomaticRedirections = value;
- }
- }
- }
+ [DynamicDependency("set_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private void SetMaxResponseHeadersLength(int value) => InvokeNativeHandlerMethod("set_MaxResponseHeadersLength", value);
+
+ [DynamicDependency("get_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private ClientCertificateOption GetClientCertificateOptions() => (ClientCertificateOption)InvokeNativeHandlerMethod("get_ClientCertificateOptions");
+
+ [DynamicDependency("set_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private void SetClientCertificateOptions(ClientCertificateOption value) => InvokeNativeHandlerMethod("set_ClientCertificateOptions", value);
+
+ [DynamicDependency("get_ClientCertificates", NativeHandlerType, AssemblyName)]
+ private X509CertificateCollection GetClientCertificates() => (X509CertificateCollection)InvokeNativeHandlerMethod("get_ClientCertificates");
+
+ [DynamicDependency("get_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private bool GetCheckCertificateRevocationList() => (bool)InvokeNativeHandlerMethod("get_CheckCertificateRevocationList");
+
+ [DynamicDependency("set_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private void SetCheckCertificateRevocationList(bool value) => InvokeNativeHandlerMethod("set_CheckCertificateRevocationList", value);
+
+ [DynamicDependency("get_SslProtocols", NativeHandlerType, AssemblyName)]
+ private SslProtocols GetSslProtocols() => (SslProtocols)InvokeNativeHandlerMethod("get_SslProtocols");
+
+ [DynamicDependency("set_SslProtocols", NativeHandlerType, AssemblyName)]
+ private void SetSslProtocols(SslProtocols value) => InvokeNativeHandlerMethod("set_SslProtocols", value);
+
+ [DynamicDependency("get_Properties", NativeHandlerType, AssemblyName)]
+ private IDictionary<string, object?> GetProperties() => (IDictionary<string, object?>)InvokeNativeHandlerMethod("get_Properties");
+
+ [DynamicDependency("get_SupportsAutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsAutomaticDecompression() => (bool)InvokeNativeHandlerMethod("get_SupportsAutomaticDecompression");
+
+ [DynamicDependency("get_SupportsProxy", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsProxy() => (bool)InvokeNativeHandlerMethod("get_SupportsProxy");
+
+ [DynamicDependency("get_SupportsRedirectConfiguration", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsRedirectConfiguration() => (bool)InvokeNativeHandlerMethod("get_SupportsRedirectConfiguration");
[DynamicDependency("get_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
private int GetMaxAutomaticRedirections() => (int)InvokeNativeHandlerMethod("get_MaxAutomaticRedirections");
private static readonly ConcurrentDictionary<string, MethodInfo?> s_cachedMethods =
new ConcurrentDictionary<string, MethodInfo?>();
+ private ClientCertificateOption _clientCertificateOptions;
+
private volatile bool _disposed;
public HttpClientHandler()
{
_socketHandler = new SocketsHttpHandler();
handler = _socketHandler;
+ ClientCertificateOptions = ClientCertificateOption.Manual;
}
if (DiagnosticsHandler.IsGloballyEnabled())
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public ICredentials? DefaultProxyCredentials
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetDefaultProxyCredentials();
+ }
+ else
+ {
+ return _socketHandler!.DefaultProxyCredentials;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetDefaultProxyCredentials(value);
+ }
+ else
+ {
+ _socketHandler!.DefaultProxyCredentials = value;
+ }
+ }
}
[UnsupportedOSPlatform("browser")]
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public int MaxConnectionsPerServer
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetMaxConnectionsPerServer();
+ }
+ else
+ {
+ return _socketHandler!.MaxConnectionsPerServer;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetMaxConnectionsPerServer(value);
+ }
+ else
+ {
+ _socketHandler!.MaxConnectionsPerServer = value;
+ }
+ }
}
public long MaxRequestContentBufferSize
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public int MaxResponseHeadersLength
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetMaxResponseHeadersLength();
+ }
+ else
+ {
+ return _socketHandler!.MaxResponseHeadersLength;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetMaxResponseHeadersLength(value);
+ }
+ else
+ {
+ _socketHandler!.MaxResponseHeadersLength = value;
+ }
+ }
}
- [UnsupportedOSPlatform("android")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public ClientCertificateOption ClientCertificateOptions
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetClientCertificateOptions();
+ }
+ else
+ {
+ return _clientCertificateOptions;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetClientCertificateOptions(value);
+ }
+ else
+ {
+ switch (value)
+ {
+ case ClientCertificateOption.Manual:
+ ThrowForModifiedManagedSslOptionsIfStarted();
+ _clientCertificateOptions = value;
+ _socketHandler!.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => CertificateHelper.GetEligibleClientCertificate(ClientCertificates)!;
+ break;
+
+ case ClientCertificateOption.Automatic:
+ ThrowForModifiedManagedSslOptionsIfStarted();
+ _clientCertificateOptions = value;
+ _socketHandler!.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => CertificateHelper.GetEligibleClientCertificate()!;
+ break;
+
+ default:
+ throw new ArgumentOutOfRangeException(nameof(value));
+ }
+ }
+ }
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public X509CertificateCollection ClientCertificates
{
get
{
- throw new PlatformNotSupportedException();
+ if (IsNativeHandlerEnabled)
+ {
+ return GetClientCertificates();
+ }
+ else
+ {
+ if (ClientCertificateOptions != ClientCertificateOption.Manual)
+ {
+ throw new InvalidOperationException(SR.Format(SR.net_http_invalid_enable_first, nameof(ClientCertificateOptions), nameof(ClientCertificateOption.Manual)));
+ }
+
+ return _socketHandler!.SslOptions.ClientCertificates ??
+ (_socketHandler!.SslOptions.ClientCertificates = new X509CertificateCollection());
+ }
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? ServerCertificateCustomValidationCallback
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ throw new PlatformNotSupportedException();
+ }
+ else
+ {
+ return (_socketHandler!.SslOptions.RemoteCertificateValidationCallback?.Target as ConnectHelper.CertificateCallbackMapper)?.FromHttpClientHandler;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ throw new PlatformNotSupportedException();
+ }
+ else
+ {
+ ThrowForModifiedManagedSslOptionsIfStarted();
+ _socketHandler!.SslOptions.RemoteCertificateValidationCallback = value != null ?
+ new ConnectHelper.CertificateCallbackMapper(value).ForSocketsHttpHandler :
+ null;
+ }
+ }
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public bool CheckCertificateRevocationList
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetCheckCertificateRevocationList();
+ }
+ else
+ {
+ return _socketHandler!.SslOptions.CertificateRevocationCheckMode == X509RevocationMode.Online;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetCheckCertificateRevocationList(value);
+ }
+ else
+ {
+ ThrowForModifiedManagedSslOptionsIfStarted();
+ _socketHandler!.SslOptions.CertificateRevocationCheckMode = value ? X509RevocationMode.Online : X509RevocationMode.NoCheck;
+ }
+ }
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public SslProtocols SslProtocols
{
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetSslProtocols();
+ }
+ else
+ {
+ return _socketHandler!.SslOptions.EnabledSslProtocols;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetSslProtocols(value);
+ }
+ else
+ {
+ ThrowForModifiedManagedSslOptionsIfStarted();
+ _socketHandler!.SslOptions.EnabledSslProtocols = value;
+ }
+ }
+ }
+
+ public IDictionary<string, object?> Properties
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetProperties();
+ }
+ else
+ {
+ return _socketHandler!.Properties;
+ }
+ }
+ }
+
+ public virtual bool SupportsAutomaticDecompression
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetSupportsAutomaticDecompression();
+ }
+ else
+ {
+ return SocketsHttpHandler.SupportsAutomaticDecompression;
+ }
+ }
+ }
+
+ public virtual bool SupportsProxy
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetSupportsProxy();
+ }
+ else
+ {
+ return SocketsHttpHandler.SupportsProxy;
+ }
+ }
+ }
+
+ public virtual bool SupportsRedirectConfiguration
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetSupportsRedirectConfiguration();
+ }
+ else
+ {
+ return SocketsHttpHandler.SupportsRedirectConfiguration;
+ }
+ }
+ }
+
+ [UnsupportedOSPlatform("browser")]
+ public DecompressionMethods AutomaticDecompression
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetAutomaticDecompression();
+ }
+ else
+ {
+ return _socketHandler!.AutomaticDecompression;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetAutomaticDecompression(value);
+ }
+ else
+ {
+ _socketHandler!.AutomaticDecompression = value;
+ }
+ }
}
- [UnsupportedOSPlatform("android")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public IDictionary<string, object?> Properties => throw new PlatformNotSupportedException();
+ [UnsupportedOSPlatform("browser")]
+ public bool UseProxy
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetUseProxy();
+ }
+ else
+ {
+ return _socketHandler!.UseProxy;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetUseProxy(value);
+ }
+ else
+ {
+ _socketHandler!.UseProxy = value;
+ }
+ }
+ }
+
+ [UnsupportedOSPlatform("browser")]
+ public IWebProxy? Proxy
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetProxy();
+ }
+ else
+ {
+ return _socketHandler!.Proxy;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetProxy(value!);
+ }
+ else
+ {
+ _socketHandler!.Proxy = value;
+ }
+ }
+ }
+
+ [UnsupportedOSPlatform("browser")]
+ public bool PreAuthenticate
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetPreAuthenticate();
+ }
+ else
+ {
+ return _socketHandler!.PreAuthenticate;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetPreAuthenticate(value);
+ }
+ else
+ {
+ _socketHandler!.PreAuthenticate = value;
+ }
+ }
+ }
+
+ [UnsupportedOSPlatform("browser")]
+ public int MaxAutomaticRedirections
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ return GetMaxAutomaticRedirections();
+ }
+ else
+ {
+ return _socketHandler!.MaxAutomaticRedirections;
+ }
+ }
+ set
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ SetMaxAutomaticRedirections(value);
+ }
+ else
+ {
+ _socketHandler!.MaxAutomaticRedirections = value;
+ }
+ }
+ }
//
// Attributes are commented out due to https://github.com/dotnet/arcade/issues/7585
}
}
- [UnsupportedOSPlatform("android")]
+ // lazy-load the validator func so it can be trimmed by the ILLinker if it isn't used.
+ private static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? s_dangerousAcceptAnyServerCertificateValidator;
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator =>
- throw new PlatformNotSupportedException();
+ public static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator
+ {
+ get
+ {
+ if (IsNativeHandlerEnabled)
+ {
+ throw new PlatformNotSupportedException();
+ }
+ else
+ {
+ return Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ??
+ Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
+ s_dangerousAcceptAnyServerCertificateValidator;
+ }
+ }
+ }
+
+ private void ThrowForModifiedManagedSslOptionsIfStarted()
+ {
+ // Hack to trigger an InvalidOperationException if a property that's stored on
+ // SslOptions is changed, since SslOptions itself does not do any such checks.
+ _socketHandler!.SslOptions = _socketHandler!.SslOptions;
+ }
private void CheckDisposed()
{
+++ /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;
-using System.Runtime.Versioning;
-
-namespace System.Net.Http
-{
- public partial class HttpClientHandler : HttpMessageHandler
- {
- public virtual bool SupportsAutomaticDecompression => false;
- public virtual bool SupportsProxy => false;
- public virtual bool SupportsRedirectConfiguration => true;
-
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public DecompressionMethods AutomaticDecompression
- {
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
- }
-
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public bool UseProxy
- {
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
- }
-
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public IWebProxy? Proxy
- {
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
- }
-
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public int MaxAutomaticRedirections
- {
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
- }
-
- [UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
- public bool PreAuthenticate
- {
- get => throw new PlatformNotSupportedException();
- set => throw new PlatformNotSupportedException();
- }
- }
-}
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Net.Security;
using System.Reflection;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
namespace System.Net.Http
{
private const string NativeHandlerType = "System.Net.Http.NSUrlSessionHandler";
private const string AssemblyName = "Xamarin.MacCatalyst";
+ [DynamicDependency("get_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private ICredentials? GetDefaultProxyCredentials() => (ICredentials?)InvokeNativeHandlerMethod("get_DefaultProxyCredentials");
+
+ [DynamicDependency("set_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private void SetDefaultProxyCredentials(ICredentials? value) => InvokeNativeHandlerMethod("set_DefaultProxyCredentials", value);
+
+ [DynamicDependency("get_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private int GetMaxConnectionsPerServer() => (int)InvokeNativeHandlerMethod("get_MaxConnectionsPerServer");
+
+ [DynamicDependency("set_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private void SetMaxConnectionsPerServer(int value) => InvokeNativeHandlerMethod("set_MaxConnectionsPerServer", value);
+
+ [DynamicDependency("get_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private int GetMaxResponseHeadersLength() => (int)InvokeNativeHandlerMethod("get_MaxResponseHeadersLength");
+
+ [DynamicDependency("set_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private void SetMaxResponseHeadersLength(int value) => InvokeNativeHandlerMethod("set_MaxResponseHeadersLength", value);
+
+ [DynamicDependency("get_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private ClientCertificateOption GetClientCertificateOptions() => (ClientCertificateOption)InvokeNativeHandlerMethod("get_ClientCertificateOptions");
+
+ [DynamicDependency("set_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private void SetClientCertificateOptions(ClientCertificateOption value) => InvokeNativeHandlerMethod("set_ClientCertificateOptions", value);
+
+ [DynamicDependency("get_ClientCertificates", NativeHandlerType, AssemblyName)]
+ private X509CertificateCollection GetClientCertificates() => (X509CertificateCollection)InvokeNativeHandlerMethod("get_ClientCertificates");
+
+ [DynamicDependency("get_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private bool GetCheckCertificateRevocationList() => (bool)InvokeNativeHandlerMethod("get_CheckCertificateRevocationList");
+
+ [DynamicDependency("set_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private void SetCheckCertificateRevocationList(bool value) => InvokeNativeHandlerMethod("set_CheckCertificateRevocationList", value);
+
+ [DynamicDependency("get_SslProtocols", NativeHandlerType, AssemblyName)]
+ private SslProtocols GetSslProtocols() => (SslProtocols)InvokeNativeHandlerMethod("get_SslProtocols");
+
+ [DynamicDependency("set_SslProtocols", NativeHandlerType, AssemblyName)]
+ private void SetSslProtocols(SslProtocols value) => InvokeNativeHandlerMethod("set_SslProtocols", value);
+
+ [DynamicDependency("get_Properties", NativeHandlerType, AssemblyName)]
+ private IDictionary<string, object?> GetProperties() => (IDictionary<string, object?>)InvokeNativeHandlerMethod("get_Properties");
+
+ [DynamicDependency("get_SupportsAutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsAutomaticDecompression() => (bool)InvokeNativeHandlerMethod("get_SupportsAutomaticDecompression");
+
+ [DynamicDependency("get_SupportsProxy", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsProxy() => (bool)InvokeNativeHandlerMethod("get_SupportsProxy");
+
+ [DynamicDependency("get_SupportsRedirectConfiguration", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsRedirectConfiguration() => (bool)InvokeNativeHandlerMethod("get_SupportsRedirectConfiguration");
+
+ [DynamicDependency("get_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private DecompressionMethods GetAutomaticDecompression() => (DecompressionMethods)InvokeNativeHandlerMethod("get_AutomaticDecompression");
+
+ [DynamicDependency("set_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private void SetAutomaticDecompression(DecompressionMethods value) => InvokeNativeHandlerMethod("set_AutomaticDecompression", value);
+
+ [DynamicDependency("get_UseProxy", NativeHandlerType, AssemblyName)]
+ private bool GetUseProxy() => (bool)InvokeNativeHandlerMethod("get_UseProxy");
+
+ [DynamicDependency("set_UseProxy", NativeHandlerType, AssemblyName)]
+ private void SetUseProxy(bool value) => InvokeNativeHandlerMethod("set_UseProxy", value);
+
+ [DynamicDependency("get_Proxy", NativeHandlerType, AssemblyName)]
+ private IWebProxy GetProxy() => (IWebProxy)InvokeNativeHandlerMethod("get_Proxy");
+
+ [DynamicDependency("set_Proxy", NativeHandlerType, AssemblyName)]
+ private void SetProxy(IWebProxy value) => InvokeNativeHandlerMethod("set_Proxy", value);
+
+ [DynamicDependency("get_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private bool GetPreAuthenticate() => (bool)InvokeNativeHandlerMethod("get_PreAuthenticate");
+
+ [DynamicDependency("set_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private void SetPreAuthenticate(bool value) => InvokeNativeHandlerMethod("set_PreAuthenticate", value);
+
+ [DynamicDependency("get_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private int GetMaxAutomaticRedirections() => (int)InvokeNativeHandlerMethod("get_MaxAutomaticRedirections");
+
+ [DynamicDependency("set_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private void SetMaxAutomaticRedirections(int value) => InvokeNativeHandlerMethod("set_MaxAutomaticRedirections", value);
+
[DynamicDependency("get_UseCookies", NativeHandlerType, AssemblyName)]
private bool GetUseCookies() => (bool)InvokeNativeHandlerMethod("get_UseCookies");
}
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public DecompressionMethods AutomaticDecompression
{
get => _underlyingHandler.AutomaticDecompression;
}
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public bool UseProxy
{
get => _underlyingHandler.UseProxy;
set => _underlyingHandler.Proxy = value;
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public ICredentials? DefaultProxyCredentials
{
get => _underlyingHandler.DefaultProxyCredentials;
}
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public bool PreAuthenticate
{
get => _underlyingHandler.PreAuthenticate;
}
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public int MaxAutomaticRedirections
{
get => _underlyingHandler.MaxAutomaticRedirections;
set => _underlyingHandler.MaxAutomaticRedirections = value;
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public int MaxConnectionsPerServer
{
get => _underlyingHandler.MaxConnectionsPerServer;
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public int MaxResponseHeadersLength
{
get => _underlyingHandler.MaxResponseHeadersLength;
set => _underlyingHandler.MaxResponseHeadersLength = value;
}
- [UnsupportedOSPlatform("android")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public ClientCertificateOption ClientCertificateOptions
{
get => _clientCertificateOptions;
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public X509CertificateCollection ClientCertificates
{
get
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? ServerCertificateCustomValidationCallback
{
#if TARGET_BROWSER
#endif
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public bool CheckCertificateRevocationList
{
get => _underlyingHandler.SslOptions.CertificateRevocationCheckMode == X509RevocationMode.Online;
}
}
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public SslProtocols SslProtocols
{
get => _underlyingHandler.SslOptions.EnabledSslProtocols;
}
}
- [UnsupportedOSPlatform("android")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public IDictionary<string, object?> Properties => _underlyingHandler.Properties;
//
// lazy-load the validator func so it can be trimmed by the ILLinker if it isn't used.
private static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? s_dangerousAcceptAnyServerCertificateValidator;
- [UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
- [UnsupportedOSPlatform("ios")]
- [UnsupportedOSPlatform("tvos")]
public static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator =>
Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ??
Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Net.Security;
using System.Reflection;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
namespace System.Net.Http
{
private const string NativeHandlerType = "System.Net.Http.NSUrlSessionHandler";
private const string AssemblyName = "Xamarin.iOS";
+ [DynamicDependency("get_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private ICredentials? GetDefaultProxyCredentials() => (ICredentials?)InvokeNativeHandlerMethod("get_DefaultProxyCredentials");
+
+ [DynamicDependency("set_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private void SetDefaultProxyCredentials(ICredentials? value) => InvokeNativeHandlerMethod("set_DefaultProxyCredentials", value);
+
+ [DynamicDependency("get_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private int GetMaxConnectionsPerServer() => (int)InvokeNativeHandlerMethod("get_MaxConnectionsPerServer");
+
+ [DynamicDependency("set_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private void SetMaxConnectionsPerServer(int value) => InvokeNativeHandlerMethod("set_MaxConnectionsPerServer", value);
+
+ [DynamicDependency("get_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private int GetMaxResponseHeadersLength() => (int)InvokeNativeHandlerMethod("get_MaxResponseHeadersLength");
+
+ [DynamicDependency("set_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private void SetMaxResponseHeadersLength(int value) => InvokeNativeHandlerMethod("set_MaxResponseHeadersLength", value);
+
+ [DynamicDependency("get_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private ClientCertificateOption GetClientCertificateOptions() => (ClientCertificateOption)InvokeNativeHandlerMethod("get_ClientCertificateOptions");
+
+ [DynamicDependency("set_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private void SetClientCertificateOptions(ClientCertificateOption value) => InvokeNativeHandlerMethod("set_ClientCertificateOptions", value);
+
+ [DynamicDependency("get_ClientCertificates", NativeHandlerType, AssemblyName)]
+ private X509CertificateCollection GetClientCertificates() => (X509CertificateCollection)InvokeNativeHandlerMethod("get_ClientCertificates");
+
+ [DynamicDependency("get_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private bool GetCheckCertificateRevocationList() => (bool)InvokeNativeHandlerMethod("get_CheckCertificateRevocationList");
+
+ [DynamicDependency("set_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private void SetCheckCertificateRevocationList(bool value) => InvokeNativeHandlerMethod("set_CheckCertificateRevocationList", value);
+
+ [DynamicDependency("get_SslProtocols", NativeHandlerType, AssemblyName)]
+ private SslProtocols GetSslProtocols() => (SslProtocols)InvokeNativeHandlerMethod("get_SslProtocols");
+
+ [DynamicDependency("set_SslProtocols", NativeHandlerType, AssemblyName)]
+ private void SetSslProtocols(SslProtocols value) => InvokeNativeHandlerMethod("set_SslProtocols", value);
+
+ [DynamicDependency("get_Properties", NativeHandlerType, AssemblyName)]
+ private IDictionary<string, object?> GetProperties() => (IDictionary<string, object?>)InvokeNativeHandlerMethod("get_Properties");
+
+ [DynamicDependency("get_SupportsAutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsAutomaticDecompression() => (bool)InvokeNativeHandlerMethod("get_SupportsAutomaticDecompression");
+
+ [DynamicDependency("get_SupportsProxy", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsProxy() => (bool)InvokeNativeHandlerMethod("get_SupportsProxy");
+
+ [DynamicDependency("get_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private DecompressionMethods GetAutomaticDecompression() => (DecompressionMethods)InvokeNativeHandlerMethod("get_AutomaticDecompression");
+
+ [DynamicDependency("set_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private void SetAutomaticDecompression(DecompressionMethods value) => InvokeNativeHandlerMethod("set_AutomaticDecompression", value);
+
+ [DynamicDependency("get_UseProxy", NativeHandlerType, AssemblyName)]
+ private bool GetUseProxy() => (bool)InvokeNativeHandlerMethod("get_UseProxy");
+
+ [DynamicDependency("set_UseProxy", NativeHandlerType, AssemblyName)]
+ private void SetUseProxy(bool value) => InvokeNativeHandlerMethod("set_UseProxy", value);
+
+ [DynamicDependency("get_Proxy", NativeHandlerType, AssemblyName)]
+ private IWebProxy GetProxy() => (IWebProxy)InvokeNativeHandlerMethod("get_Proxy");
+
+ [DynamicDependency("set_Proxy", NativeHandlerType, AssemblyName)]
+ private void SetProxy(IWebProxy value) => InvokeNativeHandlerMethod("set_Proxy", value);
+
+ [DynamicDependency("get_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private bool GetPreAuthenticate() => (bool)InvokeNativeHandlerMethod("get_PreAuthenticate");
+
+ [DynamicDependency("set_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private void SetPreAuthenticate(bool value) => InvokeNativeHandlerMethod("set_PreAuthenticate", value);
+
+ [DynamicDependency("get_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private int GetMaxAutomaticRedirections() => (int)InvokeNativeHandlerMethod("get_MaxAutomaticRedirections");
+
+ [DynamicDependency("set_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private void SetMaxAutomaticRedirections(int value) => InvokeNativeHandlerMethod("set_MaxAutomaticRedirections", value);
+
[DynamicDependency("get_UseCookies", NativeHandlerType, AssemblyName)]
private bool GetUseCookies() => (bool)InvokeNativeHandlerMethod("get_UseCookies");
+ [DynamicDependency("get_SupportsRedirectConfiguration", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsRedirectConfiguration() => (bool)InvokeNativeHandlerMethod("get_SupportsRedirectConfiguration");
+
[DynamicDependency("set_UseCookies", NativeHandlerType, AssemblyName)]
private void SetUseCookies(bool value) => InvokeNativeHandlerMethod("set_UseCookies", value);
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Net.Security;
using System.Reflection;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
namespace System.Net.Http
{
private const string NativeHandlerType = "System.Net.Http.NSUrlSessionHandler";
private const string AssemblyName = "Xamarin.TVOS";
+ [DynamicDependency("get_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private ICredentials? GetDefaultProxyCredentials() => (ICredentials?)InvokeNativeHandlerMethod("get_DefaultProxyCredentials");
+
+ [DynamicDependency("set_DefaultProxyCredentials", NativeHandlerType, AssemblyName)]
+ private void SetDefaultProxyCredentials(ICredentials? value) => InvokeNativeHandlerMethod("set_DefaultProxyCredentials", value);
+
+ [DynamicDependency("get_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private int GetMaxConnectionsPerServer() => (int)InvokeNativeHandlerMethod("get_MaxConnectionsPerServer");
+
+ [DynamicDependency("set_MaxConnectionsPerServer", NativeHandlerType, AssemblyName)]
+ private void SetMaxConnectionsPerServer(int value) => InvokeNativeHandlerMethod("set_MaxConnectionsPerServer", value);
+
+ [DynamicDependency("get_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private int GetMaxResponseHeadersLength() => (int)InvokeNativeHandlerMethod("get_MaxResponseHeadersLength");
+
+ [DynamicDependency("set_MaxResponseHeadersLength", NativeHandlerType, AssemblyName)]
+ private void SetMaxResponseHeadersLength(int value) => InvokeNativeHandlerMethod("set_MaxResponseHeadersLength", value);
+
+ [DynamicDependency("get_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private ClientCertificateOption GetClientCertificateOptions() => (ClientCertificateOption)InvokeNativeHandlerMethod("get_ClientCertificateOptions");
+
+ [DynamicDependency("set_ClientCertificateOptions", NativeHandlerType, AssemblyName)]
+ private void SetClientCertificateOptions(ClientCertificateOption value) => InvokeNativeHandlerMethod("set_ClientCertificateOptions", value);
+
+ [DynamicDependency("get_ClientCertificates", NativeHandlerType, AssemblyName)]
+ private X509CertificateCollection GetClientCertificates() => (X509CertificateCollection)InvokeNativeHandlerMethod("get_ClientCertificates");
+
+ [DynamicDependency("get_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private bool GetCheckCertificateRevocationList() => (bool)InvokeNativeHandlerMethod("get_CheckCertificateRevocationList");
+
+ [DynamicDependency("set_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
+ private void SetCheckCertificateRevocationList(bool value) => InvokeNativeHandlerMethod("set_CheckCertificateRevocationList", value);
+
+ [DynamicDependency("get_SslProtocols", NativeHandlerType, AssemblyName)]
+ private SslProtocols GetSslProtocols() => (SslProtocols)InvokeNativeHandlerMethod("get_SslProtocols");
+
+ [DynamicDependency("set_SslProtocols", NativeHandlerType, AssemblyName)]
+ private void SetSslProtocols(SslProtocols value) => InvokeNativeHandlerMethod("set_SslProtocols", value);
+
+ [DynamicDependency("get_Properties", NativeHandlerType, AssemblyName)]
+ private IDictionary<string, object?> GetProperties() => (IDictionary<string, object?>)InvokeNativeHandlerMethod("get_Properties");
+
+ [DynamicDependency("get_SupportsAutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsAutomaticDecompression() => (bool)InvokeNativeHandlerMethod("get_SupportsAutomaticDecompression");
+
+ [DynamicDependency("get_SupportsProxy", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsProxy() => (bool)InvokeNativeHandlerMethod("get_SupportsProxy");
+
+ [DynamicDependency("get_SupportsRedirectConfiguration", NativeHandlerType, AssemblyName)]
+ private bool GetSupportsRedirectConfiguration() => (bool)InvokeNativeHandlerMethod("get_SupportsRedirectConfiguration");
+
+ [DynamicDependency("get_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private DecompressionMethods GetAutomaticDecompression() => (DecompressionMethods)InvokeNativeHandlerMethod("get_AutomaticDecompression");
+
+ [DynamicDependency("set_AutomaticDecompression", NativeHandlerType, AssemblyName)]
+ private void SetAutomaticDecompression(DecompressionMethods value) => InvokeNativeHandlerMethod("set_AutomaticDecompression", value);
+
+ [DynamicDependency("get_UseProxy", NativeHandlerType, AssemblyName)]
+ private bool GetUseProxy() => (bool)InvokeNativeHandlerMethod("get_UseProxy");
+
+ [DynamicDependency("set_UseProxy", NativeHandlerType, AssemblyName)]
+ private void SetUseProxy(bool value) => InvokeNativeHandlerMethod("set_UseProxy", value);
+
+ [DynamicDependency("get_Proxy", NativeHandlerType, AssemblyName)]
+ private IWebProxy GetProxy() => (IWebProxy)InvokeNativeHandlerMethod("get_Proxy");
+
+ [DynamicDependency("set_Proxy", NativeHandlerType, AssemblyName)]
+ private void SetProxy(IWebProxy value) => InvokeNativeHandlerMethod("set_Proxy", value);
+
+ [DynamicDependency("get_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private bool GetPreAuthenticate() => (bool)InvokeNativeHandlerMethod("get_PreAuthenticate");
+
+ [DynamicDependency("set_PreAuthenticate", NativeHandlerType, AssemblyName)]
+ private void SetPreAuthenticate(bool value) => InvokeNativeHandlerMethod("set_PreAuthenticate", value);
+
+ [DynamicDependency("get_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private int GetMaxAutomaticRedirections() => (int)InvokeNativeHandlerMethod("get_MaxAutomaticRedirections");
+
+ [DynamicDependency("set_MaxAutomaticRedirections", NativeHandlerType, AssemblyName)]
+ private void SetMaxAutomaticRedirections(int value) => InvokeNativeHandlerMethod("set_MaxAutomaticRedirections", value);
+
[DynamicDependency("get_UseCookies", NativeHandlerType, AssemblyName)]
private bool GetUseCookies() => (bool)InvokeNativeHandlerMethod("get_UseCookies");