Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -1,148 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net.Http
{
public partial class HttpClientHandler : HttpMessageHandler
{
HttpMessageHandler wasmHandler;
public HttpClientHandler () : this (HttpClient.CreateDefaultHandler ()) { }
HttpClientHandler (HttpMessageHandler wasmHandler)
{
this.wasmHandler = wasmHandler;
}
protected override void Dispose (bool disposing)
{
if (disposing) {
if (wasmHandler != null) {
wasmHandler.Dispose ();
wasmHandler = null;
}
}
base.Dispose (disposing);
}
const string EXCEPTION_MESSAGE = "System.Net.Http.HttpClientHandler is not supported on the current platform.";
public virtual bool SupportsAutomaticDecompression => false;
public virtual bool SupportsProxy => false;
public virtual bool SupportsRedirectConfiguration => false;
public bool UseCookies {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public CookieContainer CookieContainer {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public ClientCertificateOption ClientCertificateOptions {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public X509CertificateCollection ClientCertificates {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> ServerCertificateCustomValidationCallback {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool CheckCertificateRevocationList {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public SslProtocols SslProtocols {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public DecompressionMethods AutomaticDecompression {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool UseProxy {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public IWebProxy Proxy {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public ICredentials DefaultProxyCredentials {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool PreAuthenticate {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool UseDefaultCredentials {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public ICredentials Credentials {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool AllowAutoRedirect {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public int MaxAutomaticRedirections {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public int MaxConnectionsPerServer {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public int MaxResponseHeadersLength {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public long MaxRequestContentBufferSize {
get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public IDictionary<string, object> Properties => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
protected internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
{
if (wasmHandler == null)
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
return wasmHandler.SendAsync (request, cancellationToken);
}
}
}

View File

@@ -37,6 +37,10 @@ LIB_MCS_FLAGS += -r:$(topdir)/../external/binary-reference-assemblies/build/mono
LIB_MCS_FLAGS += -d:XAMARIN_MODERN
endif
ifeq (wasm,$(PROFILE))
API_BIN_REFS := WebAssembly.Net.Http
endif
TEST_LIB_REFS = System System.Core
TEST_MCS_FLAGS =

View File

@@ -1,54 +1,7 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System.Net.Http
{
public partial class HttpClient
{
#pragma warning disable 649
private static Func<HttpMessageHandler> GetHttpMessageHandler;
#pragma warning restore 649
internal static HttpMessageHandler CreateDefaultHandler()
{
if (GetHttpMessageHandler == null)
{
Type type = Type.GetType("WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler, WebAssembly.Net.Http");
if (type == null)
return GetFallback ("Invalid WebAssembly Module? Cannot find WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler");
MethodInfo method = type.GetMethod("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
if (method == null)
return GetFallback ("Your WebAssembly version does not support obtaining of the custom HttpClientHandler");
object ret = method.Invoke(null, null);
if (ret == null)
return GetFallback ("WebAssembly returned no custom HttpClientHandler");
var handler = ret as HttpMessageHandler;
if (handler == null)
return GetFallback ($"{ret?.GetType()} is not a valid HttpMessageHandler");
return handler;
}
else
{
var handler = GetHttpMessageHandler();
if (handler == null)
return GetFallback($"Custom HttpMessageHandler is not valid");
return handler;
}
}
static HttpMessageHandler GetFallback(string message)
{
//Console.WriteLine(message + ". Defaulting to System.Net.Http.HttpClientHandler");
return new HttpClientHandler();
}
}
public partial class HttpClient
{
static HttpMessageHandler CreateDefaultHandler () => new WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler ();
}
}

View File

@@ -0,0 +1,147 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net.Http
{
public class HttpClientHandler : HttpMessageHandler
{
WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler wasmHandler;
public HttpClientHandler ()
{
wasmHandler = new WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler ();
}
protected override void Dispose (bool disposing)
{
if (disposing) {
if (wasmHandler != null) {
wasmHandler.Dispose ();
wasmHandler = null;
}
}
base.Dispose (disposing);
}
public virtual bool SupportsAutomaticDecompression => false;
public virtual bool SupportsProxy => false;
public virtual bool SupportsRedirectConfiguration => false;
public bool UseCookies {
get => throw new PlatformNotSupportedException ("Property UseCookies is not supported.");
set => throw new PlatformNotSupportedException ("Property UseCookies is not supported.");
}
public CookieContainer CookieContainer {
get => throw new PlatformNotSupportedException ("Property CookieContainer is not supported.");
set => throw new PlatformNotSupportedException ("Property CookieContainer is not supported.");
}
public ClientCertificateOption ClientCertificateOptions {
get => throw new PlatformNotSupportedException ("Property ClientCertificateOptions is not supported.");
set => throw new PlatformNotSupportedException ("Property ClientCertificateOptions is not supported.");
}
public X509CertificateCollection ClientCertificates {
get => throw new PlatformNotSupportedException ("Property ClientCertificates is not supported.");
set => throw new PlatformNotSupportedException ("Property ClientCertificates is not supported.");
}
public Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> ServerCertificateCustomValidationCallback {
get => throw new PlatformNotSupportedException ("Property ServerCertificateCustomValidationCallback is not supported.");
set => throw new PlatformNotSupportedException ("Property ServerCertificateCustomValidationCallback is not supported.");
}
public bool CheckCertificateRevocationList {
get => throw new PlatformNotSupportedException ("Property CheckCertificateRevocationList is not supported.");
set => throw new PlatformNotSupportedException ("Property CheckCertificateRevocationList is not supported.");
}
public SslProtocols SslProtocols {
get => throw new PlatformNotSupportedException ("Property SslProtocols is not supported.");
set => throw new PlatformNotSupportedException ("Property SslProtocols is not supported.");
}
public DecompressionMethods AutomaticDecompression {
get => throw new PlatformNotSupportedException ("Property AutomaticDecompression is not supported.");
set => throw new PlatformNotSupportedException ("Property AutomaticDecompression is not supported.");
}
public bool UseProxy {
get => throw new PlatformNotSupportedException ("Property UseProxy is not supported.");
set => throw new PlatformNotSupportedException ("Property UseProxy is not supported.");
}
public IWebProxy Proxy {
get => throw new PlatformNotSupportedException ("Property Proxy is not supported.");
set => throw new PlatformNotSupportedException ("Property Proxy is not supported.");
}
public ICredentials DefaultProxyCredentials {
get => throw new PlatformNotSupportedException ("Property DefaultProxyCredentials is not supported.");
set => throw new PlatformNotSupportedException ("Property DefaultProxyCredentials is not supported.");
}
public bool PreAuthenticate {
get => throw new PlatformNotSupportedException ("Property PreAuthenticate is not supported.");
set => throw new PlatformNotSupportedException ("Property PreAuthenticate is not supported.");
}
public bool UseDefaultCredentials {
get => throw new PlatformNotSupportedException ("Property UseDefaultCredentials is not supported.");
set => throw new PlatformNotSupportedException ("Property UseDefaultCredentials is not supported.");
}
public ICredentials Credentials {
get => throw new PlatformNotSupportedException ("Property Credentials is not supported.");
set => throw new PlatformNotSupportedException ("Property Credentials is not supported.");
}
public bool AllowAutoRedirect {
get => throw new PlatformNotSupportedException ("Property AllowAutoRedirect is not supported.");
set => throw new PlatformNotSupportedException ("Property AllowAutoRedirect is not supported.");
}
public int MaxAutomaticRedirections {
get => throw new PlatformNotSupportedException ("Property MaxAutomaticRedirections is not supported.");
set => throw new PlatformNotSupportedException ("Property MaxAutomaticRedirections is not supported.");
}
public int MaxConnectionsPerServer {
get => throw new PlatformNotSupportedException ("Property MaxConnectionsPerServer is not supported.");
set => throw new PlatformNotSupportedException ("Property MaxConnectionsPerServer is not supported.");
}
public int MaxResponseHeadersLength {
get => throw new PlatformNotSupportedException ("Property MaxResponseHeadersLength is not supported.");
set => throw new PlatformNotSupportedException ("Property MaxResponseHeadersLength is not supported.");
}
public long MaxRequestContentBufferSize {
get => throw new PlatformNotSupportedException ("Property MaxRequestContentBufferSize is not supported.");
set => throw new PlatformNotSupportedException ("Property MaxRequestContentBufferSize is not supported.");
}
public IDictionary<string, object> Properties => throw new PlatformNotSupportedException ("Property Properties is not supported.");
public static Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator { get; } = delegate { return true; };
protected internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
{
if (wasmHandler == null)
throw new ObjectDisposedException (GetType().ToString());
return wasmHandler.SendAsync (request, cancellationToken);
}
}
}

View File

@@ -1,6 +0,0 @@
HttpClient.DefaultHandler.cs
HttpClientHandler.cs
HttpClientHandler.DefaultHandler.cs
HttpClientHandler.SocketsHandler.cs
corefx/SocketsHttpHandler.Mono.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/*.cs

View File

@@ -1,3 +1,34 @@
#include socketshandler.sources
HttpClientHandler.wasm.cs
Assembly/AssemblyInfo.cs
corefx/NetEventSource.Http.cs
System.Net.Http/HttpClientHandler.wasm.cs
System.Net.Http/HttpClient.wasm.cs
HttpRequestMessage.Mono.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/Headers/*.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/ByteArrayContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/ByteArrayHelpers.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/ClientCertificateOption.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/DelegatingHandler.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/FormUrlEncodedContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpCompletionOption.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpMessageHandler.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpMessageInvoker.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpMethod.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpParseResult.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpRequestException.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/HttpUtilities.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/MessageProcessingHandler.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/MultipartContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/MultipartFormDataContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/ReadOnlyMemoryContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/StreamContent.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/StreamToStreamCopy.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/StringContent.cs