Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed HttpClientHandler dead code and folded .Core file. #38408

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<Compile Include="System\Net\Http\HttpBaseStream.cs" />
<Compile Include="System\Net\Http\HttpClient.cs" />
<Compile Include="System\Net\Http\HttpClientHandler.cs" />
<Compile Include="System\Net\Http\HttpClientHandler.Core.cs" />
<Compile Include="System\Net\Http\HttpCompletionOption.cs" />
<Compile Include="System\Net\Http\HttpContent.cs" />
<Compile Include="System\Net\Http\HttpMessageHandler.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be calling GetType().ToString() expensive, why not use ```typeof```` directly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetType() will be the derived type if there is one. And while it's more expensive than a const, it pales in comparison to the cost of the exception that's about to be thrown.

}
}
}
}