Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Keep SocketsHttpHandler out of UAP builds
Browse files Browse the repository at this point in the history
SocketsHttpHandler is not supported in uap and is currently leaking into UAP builds since they've been disabled for a few weeks. Adjust the contract so it's not available to UAP, and clean the implementation assembly so SocketsHttpHandler internals don't leak out into HttpClientHandler.Core.cs.
  • Loading branch information
nattress committed Feb 28, 2018
1 parent 13262f6 commit 30d10f5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 deletions.
35 changes: 35 additions & 0 deletions src/System.Net.Http/ref/System.Net.Http.SocketsHttpHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------


namespace System.Net.Http
{
public sealed class SocketsHttpHandler : HttpMessageHandler
{
public SocketsHttpHandler() { }
public bool AllowAutoRedirect { get { throw null; } set { } }
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
public System.TimeSpan ConnectTimeout { get; set; }
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
public System.Net.ICredentials Credentials { get { throw null; } set { } }
public System.Net.ICredentials DefaultProxyCredentials { get { throw null; } set { } }
public System.TimeSpan Expect100ContinueTimeout { get; set; }
public int MaxAutomaticRedirections { get { throw null; } set { } }
public int MaxConnectionsPerServer { get { throw null; } set { } }
public int MaxResponseHeadersLength { get { throw null; } set { } }
public bool PreAuthenticate { get { throw null; } set { } }
public System.TimeSpan PooledConnectionIdleTimeout { get { throw null; } set { } }
public System.TimeSpan PooledConnectionLifetime { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Properties { get { throw null; } }
public System.Net.IWebProxy Proxy { get { throw null; } set { } }
public System.Net.Security.SslClientAuthenticationOptions SslOptions { get { throw null; } set { } }
public bool UseCookies { get { throw null; } set { } }
public bool UseProxy { get { throw null; } set { } }
protected override void Dispose(bool disposing) { }
protected internal override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; }
}
}
24 changes: 0 additions & 24 deletions src/System.Net.Http/ref/System.Net.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,30 +236,6 @@ public ReadOnlyMemoryContent(System.ReadOnlyMemory<byte> content) { }
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) => throw null;
protected internal override bool TryComputeLength(out long length) => throw null;
}
public sealed class SocketsHttpHandler : HttpMessageHandler
{
public SocketsHttpHandler() { }
public bool AllowAutoRedirect { get { throw null; } set { } }
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
public System.TimeSpan ConnectTimeout { get; set; }
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
public System.Net.ICredentials Credentials { get { throw null; } set { } }
public System.Net.ICredentials DefaultProxyCredentials { get { throw null; } set { } }
public System.TimeSpan Expect100ContinueTimeout { get; set; }
public int MaxAutomaticRedirections { get { throw null; } set { } }
public int MaxConnectionsPerServer { get { throw null; } set { } }
public int MaxResponseHeadersLength { get { throw null; } set { } }
public bool PreAuthenticate { get { throw null; } set { } }
public System.TimeSpan PooledConnectionIdleTimeout { get { throw null; } set { } }
public System.TimeSpan PooledConnectionLifetime { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Properties { get { throw null; } }
public System.Net.IWebProxy Proxy { get { throw null; } set { } }
public System.Net.Security.SslClientAuthenticationOptions SslOptions { get { throw null; } set { } }
public bool UseCookies { get { throw null; } set { } }
public bool UseProxy { get { throw null; } set { } }
protected override void Dispose(bool disposing) { }
protected internal override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public partial class StreamContent : System.Net.Http.HttpContent
{
public StreamContent(System.IO.Stream content) { }
Expand Down
1 change: 1 addition & 0 deletions src/System.Net.Http/ref/System.Net.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Net.Http.cs" />
<Compile Include="System.Net.Http.SocketsHttpHandler.cs" Condition="'$(TargetGroup)' != 'uap'" />

This comment has been minimized.

Copy link
@stephentoub

stephentoub Feb 28, 2018

Member

Can we use a more generic name for things that shouldn't be in uap?

This comment has been minimized.

Copy link
@nattress

nattress Feb 28, 2018

Author Contributor

Yes, I'll use System.Net.Http.NetCoreApp.cs for this.

</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,5 @@ private void CheckDisposedOrStarted()
throw new InvalidOperationException(SR.net_http_operation_started);
}
}

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.
_socketsHttpHandler.SslOptions = _socketsHttpHandler.SslOptions;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ public int MaxResponseHeadersLength
}
}

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.
_socketsHttpHandler.SslOptions = _socketsHttpHandler.SslOptions;
}

public IDictionary<string, object> Properties => _curlHandler != null ?
_curlHandler.Properties :
_socketsHttpHandler.Properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,5 +463,13 @@ protected internal override Task<HttpResponseMessage> SendAsync(HttpRequestMessa
_socketsHttpHandler.SendAsync(request, cancellationToken);
}
}

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.
_socketsHttpHandler.SslOptions = _socketsHttpHandler.SslOptions;
}

This comment has been minimized.

Copy link
@stephentoub

stephentoub Feb 28, 2018

Member

It'd be nice if we had a file that was shared across all non-uap, so that we didn't have to duplicate this.

This comment has been minimized.

Copy link
@nattress

nattress Feb 28, 2018

Author Contributor

I'll factor it out into file shared by Unix and Win NetCoreApp


}
}

1 comment on commit 30d10f5

@stephentoub
Copy link
Member

Choose a reason for hiding this comment

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

There's a higher-level question: should we just start building SocketsHttpHandler for uap as well? Is there something blocking us from doing so?

Please sign in to comment.