diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 215bd71c8c080..a5138aa83e7e3 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -31,7 +31,6 @@ - diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs deleted file mode 100644 index ee5641fbf9a5f..0000000000000 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs +++ /dev/null @@ -1,66 +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.Globalization; - -namespace System.Net.Http -{ - public partial class HttpClientHandler : HttpMessageHandler - { - // This partial implementation contains members common to Windows and Unix running on .NET Core. - - private bool _operationStarted = false; - private volatile bool _disposed = false; - - public long MaxRequestContentBufferSize - { - // This property is not supported. In the .NET Framework it was only used when the handler needed to - // automatically buffer the request content. That only happened if neither 'Content-Length' nor - // 'Transfer-Encoding: chunked' request headers were specified. So, the handler thus needed to buffer - // in the request content to determine its length and then would choose 'Content-Length' semantics when - // POST'ing. In .NET Core, the handler will resolve the ambiguity by always choosing - // 'Transfer-Encoding: chunked'. The handler will never automatically buffer in the request content. - get - { - return 0; // Returning zero is appropriate since in .NET Framework it means no limit. - } - - set - { - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - if (value > HttpContent.MaxBufferSize) - { - throw new ArgumentOutOfRangeException(nameof(value), value, - SR.Format(CultureInfo.InvariantCulture, SR.net_http_content_buffersize_limit, - HttpContent.MaxBufferSize)); - } - - CheckDisposedOrStarted(); - - // No-op on property setter. - } - } - - private void CheckDisposed() - { - if (_disposed) - { - throw new ObjectDisposedException(GetType().ToString()); - } - } - - private void CheckDisposedOrStarted() - { - CheckDisposed(); - if (_operationStarted) - { - throw new InvalidOperationException(SR.net_http_operation_started); - } - } - } -} diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs index b3d03a50568f9..bffbe38568d70 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs @@ -2,6 +2,7 @@ // 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.Globalization; using System.Net.Security; using System.Collections.Generic; using System.Security.Authentication; @@ -21,6 +22,8 @@ public partial class HttpClientHandler : HttpMessageHandler private readonly DiagnosticsHandler _diagnosticsHandler; private ClientCertificateOption _clientCertificateOptions; + private volatile bool _disposed = false; + public HttpClientHandler() { #if TARGETS_BROWSER @@ -143,6 +146,39 @@ public int MaxConnectionsPerServer set => _underlyingHandler.MaxConnectionsPerServer = value; } + public long MaxRequestContentBufferSize + { + // This property is not supported. In the .NET Framework it was only used when the handler needed to + // automatically buffer the request content. That only happened if neither 'Content-Length' nor + // 'Transfer-Encoding: chunked' request headers were specified. So, the handler thus needed to buffer + // in the request content to determine its length and then would choose 'Content-Length' semantics when + // POST'ing. In .NET Core, the handler will resolve the ambiguity by always choosing + // 'Transfer-Encoding: chunked'. The handler will never automatically buffer in the request content. + get + { + return 0; // Returning zero is appropriate since in .NET Framework it means no limit. + } + + set + { + if (value < 0) + { + throw new ArgumentOutOfRangeException(nameof(value)); + } + + if (value > HttpContent.MaxBufferSize) + { + throw new ArgumentOutOfRangeException(nameof(value), value, + SR.Format(CultureInfo.InvariantCulture, SR.net_http_content_buffersize_limit, + HttpContent.MaxBufferSize)); + } + + CheckDisposed(); + + // No-op on property setter. + } + } + public int MaxResponseHeadersLength { get => _underlyingHandler.MaxResponseHeadersLength; @@ -264,5 +300,13 @@ private void ThrowForModifiedManagedSslOptionsIfStarted() // SslOptions is changed, since SslOptions itself does not do any such checks. _underlyingHandler.SslOptions = _underlyingHandler.SslOptions; } + + private void CheckDisposed() + { + if (_disposed) + { + throw new ObjectDisposedException(GetType().ToString()); + } + } } }