Imported Upstream version 6.8.0.73

Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-12-10 18:00:56 +00:00
parent bceda29824
commit 73ee7591e8
1043 changed files with 16271 additions and 22080 deletions

View File

@@ -63,7 +63,7 @@ namespace System.Net.Http
return Task.FromResult<Stream> (new MemoryStream (content, offset, count));
}
protected internal override Task SerializeToStreamAsync (Stream stream, TransportContext context)
protected override Task SerializeToStreamAsync (Stream stream, TransportContext context)
{
return stream.WriteAsync (content, offset, count);
}

View File

@@ -44,7 +44,12 @@ namespace System.Net.Http
long buffer_size;
TimeSpan timeout;
#if !XAMARIN_MODERN && !WASM
#if XAMARIN_MODERN
public HttpClient ()
: this (CreateDefaultHandler (), true)
{
}
#elif !WASM
public HttpClient ()
: this (new HttpClientHandler (), true)
{

View File

@@ -3,12 +3,6 @@ using System.Reflection;
namespace System.Net.Http {
public partial class HttpClient {
public HttpClient ()
: this (CreateDefaultHandler ())
{
}
static HttpMessageHandler CreateDefaultHandler ()
{
return ObjCRuntime.RuntimeOptions.GetHttpMessageHandler ();

View File

@@ -1,179 +0,0 @@
//
// System.Net.Http/HttpClientHandler.cs
//
// Author:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using System.Threading;
namespace System.Net.Http
{
public class HttpClientHandler : HttpMessageHandler
{
const string EXCEPTION_MESSAGE = "System.Net.Http.HttpClientHandler is not supported on the current platform.";
public HttpClientHandler ()
{
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool AllowAutoRedirect {
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 ClientCertificateOption ClientCertificateOptions {
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 ICredentials Credentials {
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 long MaxRequestContentBufferSize {
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 IWebProxy Proxy {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public virtual bool SupportsAutomaticDecompression {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public virtual bool SupportsProxy {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public virtual bool SupportsRedirectConfiguration {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public bool UseCookies {
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 bool UseProxy {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
protected override void Dispose (bool disposing)
{
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
HttpResponseMessage CreateResponseMessage (HttpWebResponse wr, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
{
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
protected internal async override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
{
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
}
public bool CheckCertificateRevocationList {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public X509CertificateCollection ClientCertificates {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
public ICredentials DefaultProxyCredentials {
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 IDictionary<string,object> Properties {
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 SslProtocols SslProtocols {
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
}
// Only used in MonoWebRequestHandler and ignored by the other handlers.
internal void SetWebRequestTimeout (TimeSpan timeout) => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
// NS2.1:
public static System.Func<System.Net.Http.HttpRequestMessage, System.Security.Cryptography.X509Certificates.X509Certificate2, System.Security.Cryptography.X509Certificates.X509Chain, System.Net.Security.SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator => throw new PlatformNotSupportedException ();
}
}

View File

@@ -0,0 +1,148 @@
// 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
{
HttpMessageHandler platformHandler;
public HttpClientHandler ()
{
// Ensure GetHttpMessageHandler does not recursively call new HttpClientHandler ()
platformHandler = ObjCRuntime.RuntimeOptions.GetHttpMessageHandler ();
}
protected override void Dispose (bool disposing)
{
if (disposing) {
if (platformHandler != null) {
platformHandler.Dispose ();
platformHandler = 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 ();
set => throw new PlatformNotSupportedException ();
}
public CookieContainer CookieContainer {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public ClientCertificateOption ClientCertificateOptions {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public X509CertificateCollection ClientCertificates {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> ServerCertificateCustomValidationCallback {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public bool CheckCertificateRevocationList {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public SslProtocols SslProtocols {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public DecompressionMethods AutomaticDecompression {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public bool UseProxy {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public IWebProxy Proxy {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public ICredentials DefaultProxyCredentials {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public bool PreAuthenticate {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public bool UseDefaultCredentials {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public ICredentials Credentials {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public bool AllowAutoRedirect {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public int MaxAutomaticRedirections {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public int MaxConnectionsPerServer {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public int MaxResponseHeadersLength {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public long MaxRequestContentBufferSize {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
public IDictionary<string, object> Properties => throw new PlatformNotSupportedException ();
public static Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator { get; } = delegate { return true; };
protected internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
{
if (platformHandler == null)
throw new ObjectDisposedException (GetType().ToString());
return platformHandler.SendAsync (request, cancellationToken);
}
}
}

View File

@@ -212,7 +212,12 @@ namespace System.Net.Http
return value.Length;
}
protected internal abstract Task SerializeToStreamAsync (Stream stream, TransportContext context);
internal Task SerializeToStreamAsync_internal (Stream stream, TransportContext context)
{
return SerializeToStreamAsync (stream, context);
}
protected abstract Task SerializeToStreamAsync (Stream stream, TransportContext context);
protected internal abstract bool TryComputeLength (out long length);
}
}

View File

@@ -122,7 +122,7 @@ namespace System.Net.Http
base.Dispose (disposing);
}
protected internal override async Task SerializeToStreamAsync (Stream stream, TransportContext context)
protected override async Task SerializeToStreamAsync (Stream stream, TransportContext context)
{
// RFC 2046
//
@@ -156,7 +156,7 @@ namespace System.Net.Http
sb.Clear ();
await stream.WriteAsync (buffer, 0, buffer.Length).ConfigureAwait (false);
await c.SerializeToStreamAsync (stream, context).ConfigureAwait (false);
await c.SerializeToStreamAsync_internal (stream, context).ConfigureAwait (false);
if (i != nested_content.Count - 1) {
sb.Append ('\r').Append ('\n');

View File

@@ -87,7 +87,7 @@ namespace System.Net.Http
base.Dispose (disposing);
}
protected internal override Task SerializeToStreamAsync (Stream stream, TransportContext context)
protected override Task SerializeToStreamAsync (Stream stream, TransportContext context)
{
if (contentCopied) {
if (!content.CanSeek) {

View File

@@ -120,10 +120,14 @@ namespace MonoTests.System.Net.Http.Headers
headers.TryAddWithoutValidation("User-Agent", "agent2/2.0");
Assert.AreEqual (1, headers.UserAgent.Count, "#1");
#if !MONOTOUCH_WATCH
if (HttpClientTestHelpers.UsingSocketsHandler)
#endif
Assert.AreEqual ("agent2/2.0 user,agent/1.0", headers.UserAgent.ToString (), "#2");
#if !MONOTOUCH_WATCH
else
Assert.AreEqual ("agent2/2.0user,agent/1.0", headers.UserAgent.ToString (), "#2");
#endif
Assert.AreEqual ("User-Agent: agent2/2.0 user,agent/1.0\r\n", headers.ToString (), "#3");

View File

@@ -61,8 +61,10 @@ namespace MonoTests.System.Net.Http.Headers
if (HttpClientTestHelpers.UsingSocketsHandler)
Assert.Fail ("#1");
} catch (FormatException) {
#if !MONOTOUCH_WATCH
if (!HttpClientTestHelpers.UsingSocketsHandler)
throw;
#endif
}
}

View File

@@ -189,7 +189,9 @@ namespace MonoTests.System.Net.Http
[Test]
#if FEATURE_NO_BSD_SOCKETS
#if !MONOTOUCH_WATCH
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
#endif
public void Ctor_HttpClientHandler ()
{
@@ -1109,7 +1111,9 @@ namespace MonoTests.System.Net.Http
[Test]
#if FEATURE_NO_BSD_SOCKETS
#if !MONOTOUCH_WATCH
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
#endif
public void Send_Invalid ()
{

View File

@@ -61,13 +61,17 @@ namespace MonoTests.System.Net.Http
Assert.AreEqual (HttpMethod.Get, m.Method, "#3");
Assert.IsNotNull (m.Properties, "#4");
Assert.IsNull (m.RequestUri, "#5");
#if !MONOTOUCH_WATCH
if (HttpClientTestHelpers.UsingSocketsHandler) {
#endif
Assert.AreEqual (new Version (2, 0), m.Version, "#6");
Assert.AreEqual ("Method: GET, RequestUri: '<null>', Version: 2.0, Content: <null>, Headers:\r\n{\r\n}", m.ToString (), "#7");
#if !MONOTOUCH_WATCH
} else {
Assert.AreEqual (new Version (1, 1), m.Version, "#6");
Assert.AreEqual ("Method: GET, RequestUri: '<null>', Version: 1.1, Content: <null>, Headers:\r\n{\r\n}", m.ToString (), "#7");
}
#endif
}
[Test]
@@ -670,10 +674,14 @@ namespace MonoTests.System.Net.Http
// .NET encloses the "Age: vv" with two whitespaces.
var normalized = Regex.Replace (message.ToString (), @"\s", "");
#if !MONOTOUCH_WATCH
if (HttpClientTestHelpers.UsingSocketsHandler)
#endif
Assert.AreEqual ("Method:GET,RequestUri:'<null>',Version:2.0,Content:<null>,Headers:{Age:vv}", normalized, "#3");
#if !MONOTOUCH_WATCH
else
Assert.AreEqual ("Method:GET,RequestUri:'<null>',Version:1.1,Content:<null>,Headers:{Age:vv}", normalized, "#3");
#endif
}
[Test]

View File

@@ -275,10 +275,14 @@ namespace MonoTests.System.Net.Http
Assert.AreEqual ("v1", values[0]);
break;
case 1:
#if !MONOTOUCH_WATCH
if (HttpClientTestHelpers.UsingSocketsHandler)
#endif
Assert.AreEqual ("Cache-Control", entry.Key);
#if !MONOTOUCH_WATCH
else
Assert.AreEqual ("cache-control", entry.Key);
#endif
values = entry.Value.ToList ();
Assert.AreEqual (1, values.Count);
Assert.AreEqual ("audio", values[0]);

View File

@@ -7,7 +7,7 @@ namespace System.Net.Http
public sealed partial class ReadOnlyMemoryContent : System.Net.Http.HttpContent
{
public ReadOnlyMemoryContent(System.ReadOnlyMemory<byte> content) => throw new PlatformNotSupportedException();
protected internal override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) => throw new PlatformNotSupportedException();
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) => throw new PlatformNotSupportedException();
protected internal override bool TryComputeLength(out long length) => throw new PlatformNotSupportedException();
}
}

View File

@@ -0,0 +1 @@
HttpClient.DefaultHandler.cs

View File

@@ -1,2 +1,2 @@
#include legacy.sources
#include socketshandler.sources
System.Net.Http/HttpClient.macios.cs

View File

@@ -0,0 +1 @@
#include monotouch_System.Net.Http.dll.exclude.sources

View File

@@ -1,2 +1 @@
#include legacy.sources
System.Net.Http/HttpClient.macios.cs
#include monotouch_System.Net.Http.dll.sources

View File

@@ -1,7 +0,0 @@
HttpClientHandler.cs
HttpClientHandler.Legacy.cs
IMonoHttpClientHandler.cs
MonoWebRequestHandler.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CancellationHelper.cs
../../../external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs

View File

@@ -1,3 +1,34 @@
#include legacy.sources
System.Net.Http/HttpClientHandler.platformnotsupported.cs
Assembly/AssemblyInfo.cs
corefx/NetEventSource.Http.cs
System.Net.Http/HttpClientHandler.xi.cs
System.Net.Http/HttpClient.macios.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

Some files were not shown because too many files have changed in this diff Show More