Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,73 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.ServicePoint.Tests", "tests\System.Net.ServicePoint.Tests.csproj", "{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}"
ProjectSection(ProjectDependencies) = postProject
{53D09AF4-0C13-4197-B8AD-9746F0374E88} = {53D09AF4-0C13-4197-B8AD-9746F0374E88}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{350C956A-B4ED-4376-9B04-2908528D10FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.ServicePoint", "ref\System.Net.ServicePoint.csproj", "{14FAFC3A-8266-45C7-8604-8C2CB567E50D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827B5CCD-073A-4A75-9661-73D54F0A3528}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.ServicePoint", "src\System.Net.ServicePoint.csproj", "{53D09AF4-0C13-4197-B8AD-9746F0374E88}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{096E7AD0-17A2-4EAF-9AC5-2F0FC67A4112}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU = DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU
ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU = ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU
DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU = DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU
ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU = ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU
DebugNETCoreAppnetstandardnetstandard|AnyCPU = DebugNETCoreAppnetstandardnetstandard|AnyCPU
ReleaseNETCoreAppnetstandardnetstandard|AnyCPU = ReleaseNETCoreAppnetstandardnetstandard|AnyCPU
DebugNETCoreAppnetstandardnetcoreapp|AnyCPU = DebugNETCoreAppnetstandardnetcoreapp|AnyCPU
ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU = ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.DebugNETCoreAppnetstandardnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}.ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.ActiveCfg = net461-Windows_NT-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.Build.0 = net461-Windows_NT-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.ActiveCfg = net461-Windows_NT-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461-Windows_NTnetstandard|AnyCPU.Build.0 = net461-Windows_NT-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net461-Windows_NT-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.Build.0 = net461-Windows_NT-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net461-Windows_NT-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnet461-Windows_NTnetcoreapp|AnyCPU.Build.0 = net461-Windows_NT-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetstandard|AnyCPU.Build.0 = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetcoreapp|AnyCPU.ActiveCfg = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.DebugNETCoreAppnetstandardnetcoreapp|AnyCPU.Build.0 = netstandard-Debug|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU.ActiveCfg = netstandard-Release|Any CPU
{53D09AF4-0C13-4197-B8AD-9746F0374E88}.ReleaseNETCoreAppnetstandardnetcoreapp|AnyCPU.Build.0 = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0D1E2954-A5C7-4B8C-932A-31EB4A96A726} = {0D1E2954-A5C7-4B8C-932A-31EB4A96A726}
{53D09AF4-0C13-4197-B8AD-9746F0374E88} = {53D09AF4-0C13-4197-B8AD-9746F0374E88}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<IsNETCoreApp>true</IsNETCoreApp>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netcoreapp;
uap;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Net.ServicePoint.csproj" />
<Project Include="System.Net.ServicePoint.csproj">
<TargetGroup>netcoreapp</TargetGroup>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,65 @@
// 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
{
public delegate System.Net.IPEndPoint BindIPEndPoint(System.Net.ServicePoint servicePoint, System.Net.IPEndPoint remoteEndPoint, int retryCount);
public class ServicePoint
{
internal ServicePoint() { }
public System.Net.BindIPEndPoint BindIPEndPointDelegate { get { throw null; } set { } }
public int ConnectionLeaseTimeout { get { throw null; } set { } }
public System.Uri Address { get { throw null; } }
public int MaxIdleTime { get { throw null; } set { } }
public bool UseNagleAlgorithm { get { throw null; } set { } }
public int ReceiveBufferSize { get { throw null; } set { } }
public bool Expect100Continue { get { throw null; } set { } }
public System.DateTime IdleSince { get { throw null; } }
public virtual System.Version ProtocolVersion { get { throw null; } }
public string ConnectionName { get { throw null; } }
public bool CloseConnectionGroup(string connectionGroupName) { throw null; }
public int ConnectionLimit { get { throw null; } set { } }
public int CurrentConnections { get { throw null; } }
public System.Security.Cryptography.X509Certificates.X509Certificate Certificate { get { throw null; } }
public System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate { get { throw null; } }
public bool SupportsPipelining { get { throw null; } }
public void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval) { throw null; }
}
public class ServicePointManager
{
public const int DefaultNonPersistentConnectionLimit = 4;
public const int DefaultPersistentConnectionLimit = 2;
private ServicePointManager() { }
public static System.Net.SecurityProtocolType SecurityProtocol { get { throw null; } set { } }
public static int MaxServicePoints { get { throw null; } set { } }
public static int DefaultConnectionLimit { get { throw null; } set { } }
public static int MaxServicePointIdleTime { get { throw null; } set { } }
public static bool UseNagleAlgorithm { get { throw null; } set { } }
public static bool Expect100Continue { get { throw null; } set { } }
public static bool EnableDnsRoundRobin { get { throw null; } set { } }
public static int DnsRefreshTimeout { get { throw null; } set { } }
public static System.Net.Security.RemoteCertificateValidationCallback ServerCertificateValidationCallback { get { throw null; } set { } }
public static bool ReusePort { get { throw null; } set { } }
public static bool CheckCertificateRevocationList { get { throw null; } set { } }
public static System.Net.Security.EncryptionPolicy EncryptionPolicy { get { throw null; } }
public static System.Net.ServicePoint FindServicePoint(System.Uri address) { throw null; }
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy proxy) { throw null; }
public static System.Net.ServicePoint FindServicePoint(System.Uri address, System.Net.IWebProxy proxy) { throw null; }
public static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval) { throw null; }
}
[Flags]
public enum SecurityProtocolType
{
SystemDefault = 0,
#pragma warning disable CS0618
Ssl3 = System.Security.Authentication.SslProtocols.Ssl3,
#pragma warning restore CS0618
Tls = System.Security.Authentication.SslProtocols.Tls,
Tls11 = System.Security.Authentication.SslProtocols.Tls11,
Tls12 = System.Security.Authentication.SslProtocols.Tls12,
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Net.ServicePoint.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Net.Primitives\ref\System.Net.Primitives.csproj" />
<ProjectReference Include="..\..\System.Net.Security\ref\System.Net.Security.csproj" />
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Security.Cryptography.X509Certificates\ref\System.Security.Cryptography.X509Certificates.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
net461-Windows_NT;
netcoreapp;
uap;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="net_proxyschemenotsupported" xml:space="preserve">
<value>The ServicePointManager does not support proxies with the {0} scheme.</value>
</data>
<data name="net_securityprotocolnotsupported" xml:space="preserve">
<value>The requested security protocol is not supported.</value>
</data>
</root>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{53D09AF4-0C13-4197-B8AD-9746F0374E88}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='net461'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net461-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net461-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="System\Net\BindIPEndPoint.cs" />
<Compile Include="System\Net\ServicePoint.cs" />
<Compile Include="System\Net\ServicePointManager.cs" />
<Compile Include="System\Net\SecurityProtocolType.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'net461'">
<TargetingPackReference Include="System" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Net.Primitives" />
<Reference Include="System.Net.Security" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Security.Cryptography.X509Certificates" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
// 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.
namespace System.Net
{
public delegate IPEndPoint BindIPEndPoint(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount);
}

View File

@@ -0,0 +1,20 @@
// 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.Security.Authentication;
namespace System.Net
{
[Flags]
public enum SecurityProtocolType
{
SystemDefault = 0,
#pragma warning disable CS0618
Ssl3 = SslProtocols.Ssl3,
#pragma warning restore CS0618
Tls = SslProtocols.Tls,
Tls11 = SslProtocols.Tls11,
Tls12 = SslProtocols.Tls12,
}
}

View File

@@ -0,0 +1,116 @@
// 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.Diagnostics;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
namespace System.Net
{
public class ServicePoint
{
private int _connectionLeaseTimeout = -1;
private int _maxIdleTime = 100 * 1000;
private int _receiveBufferSize = -1;
private int _connectionLimit;
internal ServicePoint(Uri address)
{
Debug.Assert(address != null);
Address = address;
ConnectionName = address.Scheme;
}
public BindIPEndPoint BindIPEndPointDelegate { get; set; }
public int ConnectionLeaseTimeout
{
get { return _connectionLeaseTimeout; }
set
{
if (value < Timeout.Infinite)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_connectionLeaseTimeout = value;
}
}
public Uri Address { get; }
public int MaxIdleTime
{
get { return _maxIdleTime; }
set
{
if (value < Timeout.Infinite)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_maxIdleTime = value;
}
}
public bool UseNagleAlgorithm { get; set; }
public int ReceiveBufferSize
{
get { return _receiveBufferSize; }
set
{
if (value < -1)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_receiveBufferSize = value;
}
}
public bool Expect100Continue { get; set; }
public DateTime IdleSince { get; internal set; }
public virtual Version ProtocolVersion { get; internal set; } = new Version(1, 1);
public string ConnectionName { get; }
public bool CloseConnectionGroup(string connectionGroupName) => true;
public int ConnectionLimit
{
get { return _connectionLimit; }
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_connectionLimit = value;
}
}
public int CurrentConnections => 0;
public X509Certificate Certificate { get; internal set; }
public X509Certificate ClientCertificate { get; internal set; }
public bool SupportsPipelining { get; internal set; } = true;
public void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval)
{
if (enabled)
{
if (keepAliveTime <= 0)
{
throw new ArgumentOutOfRangeException(nameof(keepAliveTime));
}
if (keepAliveInterval <= 0)
{
throw new ArgumentOutOfRangeException(nameof(keepAliveInterval));
}
}
}
}
}

View File

@@ -0,0 +1,220 @@
// 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.Concurrent;
using System.Collections.Generic;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
namespace System.Net
{
public class ServicePointManager
{
public const int DefaultNonPersistentConnectionLimit = 4;
public const int DefaultPersistentConnectionLimit = 2;
private static readonly ConcurrentDictionary<string, WeakReference<ServicePoint>> s_servicePointTable = new ConcurrentDictionary<string, WeakReference<ServicePoint>>();
private static SecurityProtocolType s_securityProtocolType = SecurityProtocolType.SystemDefault;
private static int s_connectionLimit = 2;
private static int s_maxServicePoints = 0;
private static int s_maxServicePointIdleTime = 100 * 1000;
private static int s_dnsRefreshTimeout = 2 * 60 * 1000;
private ServicePointManager() { }
public static SecurityProtocolType SecurityProtocol
{
get { return s_securityProtocolType; }
set
{
ValidateSecurityProtocol(value);
s_securityProtocolType = value;
}
}
private static void ValidateSecurityProtocol(SecurityProtocolType value)
{
SecurityProtocolType allowed = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
if ((value & ~allowed) != 0)
{
throw new NotSupportedException(SR.net_securityprotocolnotsupported);
}
}
public static int MaxServicePoints
{
get { return s_maxServicePoints; }
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
s_maxServicePoints = value;
}
}
public static int DefaultConnectionLimit
{
get { return s_connectionLimit; }
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
s_connectionLimit = value;
}
}
public static int MaxServicePointIdleTime
{
get { return s_maxServicePointIdleTime; }
set
{
if (value < Timeout.Infinite)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
s_maxServicePointIdleTime = value;
}
}
public static bool UseNagleAlgorithm { get; set; } = true;
public static bool Expect100Continue { get; set; } = true;
public static bool EnableDnsRoundRobin { get; set; }
public static int DnsRefreshTimeout
{
get { return s_dnsRefreshTimeout; }
set { s_dnsRefreshTimeout = Math.Max(-1, value); }
}
public static RemoteCertificateValidationCallback ServerCertificateValidationCallback { get; set; }
public static bool ReusePort { get; set; }
public static bool CheckCertificateRevocationList { get; set; }
public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption;
public static ServicePoint FindServicePoint(Uri address) => FindServicePoint(address, null);
public static ServicePoint FindServicePoint(string uriString, IWebProxy proxy) => FindServicePoint(new Uri(uriString), proxy);
public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy)
{
if (address == null)
{
throw new ArgumentNullException(nameof(address));
}
// If there's a proxy for this address, get the "real" address.
bool isProxyServicePoint = ProxyAddressIfNecessary(ref address, proxy);
// Create a lookup key to find the service point
string tableKey = MakeQueryString(address, isProxyServicePoint);
// Get an existing service point or create a new one
ServicePoint sp; // outside of loop to keep references alive from one iteration to the next
while (true)
{
// The table maps lookup key to a weak reference to a service point. If the table
// contains a weak ref for the key and that weak ref points to a valid ServicePoint,
// simply return it (after updating its last used time).
WeakReference<ServicePoint> wr;
if (s_servicePointTable.TryGetValue(tableKey, out wr) && wr.TryGetTarget(out sp))
{
sp.IdleSince = DateTime.Now;
return sp;
}
// Any time we don't find what we're looking for in the table, take that as an opportunity
// to scavenge the table looking for entries that have lost their service point and removing them.
foreach (KeyValuePair<string, WeakReference<ServicePoint>> entry in s_servicePointTable)
{
ServicePoint ignored;
if (!entry.Value.TryGetTarget(out ignored))
{
// We use the IDictionary.Remove method rather than TryRemove as it will only
// remove the entry from the table if both the key/value in the pair match.
// This avoids a race condition where another thread concurrently sets a new
// weak reference value for the same key, and is why when adding the new
// service point below, we don't use any weak reference object we may already
// have from the initial retrieval above.
((IDictionary<string, WeakReference<ServicePoint>>)s_servicePointTable).Remove(entry);
}
}
// There wasn't a service point in the table. Create a new one, and then store
// it back into the table. We create a new weak reference object even if we were
// able to get one above so that when we scavenge the table, we can rely on
// weak reference reference equality to know whether we're removing the same
// weak reference we saw when we enumerated.
sp = new ServicePoint(address)
{
ConnectionLimit = DefaultConnectionLimit,
IdleSince = DateTime.Now,
Expect100Continue = Expect100Continue,
UseNagleAlgorithm = UseNagleAlgorithm
};
s_servicePointTable[tableKey] = new WeakReference<ServicePoint>(sp);
// It's possible there's a race between two threads both updating the table
// at the same time. We don't want to just use GetOrAdd, as with the weak
// reference we may end up getting back a weak ref that no longer has a target.
// So we simply loop around again; in all but the most severe of circumstances, the
// next iteration will find it in the table and return it.
}
}
private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
{
if (proxy != null && !address.IsLoopback)
{
Uri proxyAddress = proxy.GetProxy(address);
if (proxyAddress != null)
{
if (proxyAddress.Scheme != Uri.UriSchemeHttp)
{
throw new NotSupportedException(SR.Format(SR.net_proxyschemenotsupported, address.Scheme));
}
address = proxyAddress;
return true;
}
}
return false;
}
private static string MakeQueryString(Uri address) => address.IsDefaultPort ?
address.Scheme + "://" + address.DnsSafeHost :
address.Scheme + "://" + address.DnsSafeHost + ":" + address.Port.ToString();
private static string MakeQueryString(Uri address, bool isProxy)
{
string queryString = MakeQueryString(address);
return isProxy ? queryString + "://proxy" : queryString;
}
public static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval)
{
if (enabled)
{
if (keepAliveTime <= 0)
{
throw new ArgumentOutOfRangeException(nameof(keepAliveTime));
}
if (keepAliveInterval <= 0)
{
throw new ArgumentOutOfRangeException(nameof(keepAliveInterval));
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
netcoreapp;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,329 @@
// 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.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Xunit;
namespace System.Net.Tests
{
public class ServicePointManagerTest
{
[Fact]
public static void RequireEncryption_ExpectedDefault()
{
Assert.Equal(EncryptionPolicy.RequireEncryption, ServicePointManager.EncryptionPolicy);
}
[Fact]
public static void CheckCertificateRevocationList_Roundtrips()
{
Assert.False(ServicePointManager.CheckCertificateRevocationList);
ServicePointManager.CheckCertificateRevocationList = true;
Assert.True(ServicePointManager.CheckCertificateRevocationList);
ServicePointManager.CheckCertificateRevocationList = false;
Assert.False(ServicePointManager.CheckCertificateRevocationList);
}
[Fact]
public static void DefaultConnectionLimit_Roundtrips()
{
Assert.Equal(2, ServicePointManager.DefaultConnectionLimit);
ServicePointManager.DefaultConnectionLimit = 20;
Assert.Equal(20, ServicePointManager.DefaultConnectionLimit);
ServicePointManager.DefaultConnectionLimit = 2;
Assert.Equal(2, ServicePointManager.DefaultConnectionLimit);
}
[Fact]
public static void DnsRefreshTimeout_Roundtrips()
{
Assert.Equal(120000, ServicePointManager.DnsRefreshTimeout);
ServicePointManager.DnsRefreshTimeout = 42;
Assert.Equal(42, ServicePointManager.DnsRefreshTimeout);
ServicePointManager.DnsRefreshTimeout = 120000;
Assert.Equal(120000, ServicePointManager.DnsRefreshTimeout);
}
[Fact]
public static void EnableDnsRoundRobin_Roundtrips()
{
Assert.False(ServicePointManager.EnableDnsRoundRobin);
ServicePointManager.EnableDnsRoundRobin = true;
Assert.True(ServicePointManager.EnableDnsRoundRobin);
ServicePointManager.EnableDnsRoundRobin = false;
Assert.False(ServicePointManager.EnableDnsRoundRobin);
}
[Fact]
public static void Expect100Continue_Roundtrips()
{
Assert.True(ServicePointManager.Expect100Continue);
ServicePointManager.Expect100Continue = false;
Assert.False(ServicePointManager.Expect100Continue);
ServicePointManager.Expect100Continue = true;
Assert.True(ServicePointManager.Expect100Continue);
}
[Fact]
public static void MaxServicePointIdleTime_Roundtrips()
{
Assert.Equal(100000, ServicePointManager.MaxServicePointIdleTime);
ServicePointManager.MaxServicePointIdleTime = 42;
Assert.Equal(42, ServicePointManager.MaxServicePointIdleTime);
ServicePointManager.MaxServicePointIdleTime = 100000;
Assert.Equal(100000, ServicePointManager.MaxServicePointIdleTime);
}
[Fact]
public static void MaxServicePoints_Roundtrips()
{
Assert.Equal(0, ServicePointManager.MaxServicePoints);
ServicePointManager.MaxServicePoints = 42;
Assert.Equal(42, ServicePointManager.MaxServicePoints);
ServicePointManager.MaxServicePoints = 0;
Assert.Equal(0, ServicePointManager.MaxServicePoints);
}
[Fact]
public static void ReusePort_Roundtrips()
{
Assert.False(ServicePointManager.ReusePort);
ServicePointManager.ReusePort = true;
Assert.True(ServicePointManager.ReusePort);
ServicePointManager.ReusePort = false;
Assert.False(ServicePointManager.ReusePort);
}
[Fact]
public static void SecurityProtocol_Roundtrips()
{
var orig = (SecurityProtocolType)0; // SystemDefault.
Assert.Equal(orig, ServicePointManager.SecurityProtocol);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
Assert.Equal(SecurityProtocolType.Tls11, ServicePointManager.SecurityProtocol);
ServicePointManager.SecurityProtocol = orig;
Assert.Equal(orig, ServicePointManager.SecurityProtocol);
}
[Fact]
public static void ServerCertificateValidationCallback_Roundtrips()
{
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
RemoteCertificateValidationCallback callback = delegate { return true; };
ServicePointManager.ServerCertificateValidationCallback = callback;
Assert.Same(callback, ServicePointManager.ServerCertificateValidationCallback);
ServicePointManager.ServerCertificateValidationCallback = null;
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
}
[Fact]
public static void UseNagleAlgorithm_Roundtrips()
{
Assert.True(ServicePointManager.UseNagleAlgorithm);
ServicePointManager.UseNagleAlgorithm = false;
Assert.False(ServicePointManager.UseNagleAlgorithm);
ServicePointManager.UseNagleAlgorithm = true;
Assert.True(ServicePointManager.UseNagleAlgorithm);
}
[Fact]
public static void InvalidArguments_Throw()
{
const int ssl2Client = 0x00000008;
const int ssl2Server = 0x00000004;
SecurityProtocolType ssl2 = (SecurityProtocolType)(ssl2Client | ssl2Server);
Assert.Throws<NotSupportedException>(() => ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3);
Assert.Throws<NotSupportedException>(() => ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | ssl2);
Assert.Throws<NotSupportedException>(() => ServicePointManager.SecurityProtocol = ssl2);
Assert.Throws<ArgumentNullException>("uriString", () => ServicePointManager.FindServicePoint((string)null, null));
Assert.Throws<ArgumentOutOfRangeException>("value", () => ServicePointManager.MaxServicePoints = -1);
Assert.Throws<ArgumentOutOfRangeException>("value", () => ServicePointManager.DefaultConnectionLimit = 0);
Assert.Throws<ArgumentOutOfRangeException>("value", () => ServicePointManager.MaxServicePointIdleTime = -2);
Assert.Throws<ArgumentOutOfRangeException>("keepAliveTime", () => ServicePointManager.SetTcpKeepAlive(true, -1, 1));
Assert.Throws<ArgumentOutOfRangeException>("keepAliveInterval", () => ServicePointManager.SetTcpKeepAlive(true, 1, -1));
Assert.Throws<ArgumentNullException>("address", () => ServicePointManager.FindServicePoint(null));
Assert.Throws<ArgumentNullException>("uriString", () => ServicePointManager.FindServicePoint((string)null, null));
Assert.Throws<ArgumentNullException>("address", () => ServicePointManager.FindServicePoint((Uri)null, null));
Assert.Throws<NotSupportedException>(() => ServicePointManager.FindServicePoint("http://anything", new FixedWebProxy("https://anything")));
ServicePoint sp = ServicePointManager.FindServicePoint("http://" + Guid.NewGuid().ToString("N"), null);
Assert.Throws<ArgumentOutOfRangeException>("value", () => sp.ConnectionLeaseTimeout = -2);
Assert.Throws<ArgumentOutOfRangeException>("value", () => sp.ConnectionLimit = 0);
Assert.Throws<ArgumentOutOfRangeException>("value", () => sp.MaxIdleTime = -2);
Assert.Throws<ArgumentOutOfRangeException>("value", () => sp.ReceiveBufferSize = -2);
Assert.Throws<ArgumentOutOfRangeException>("keepAliveTime", () => sp.SetTcpKeepAlive(true, -1, 1));
Assert.Throws<ArgumentOutOfRangeException>("keepAliveInterval", () => sp.SetTcpKeepAlive(true, 1, -1));
}
[Fact]
public static void FindServicePoint_ReturnsCachedServicePoint()
{
const string Localhost = "http://localhost";
string address1 = "http://" + Guid.NewGuid().ToString("N");
string address2 = "http://" + Guid.NewGuid().ToString("N");
Assert.NotNull(ServicePointManager.FindServicePoint(new Uri(address1)));
Assert.Same(
ServicePointManager.FindServicePoint(address1, null),
ServicePointManager.FindServicePoint(address1, null));
Assert.Same(
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address1)),
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address1)));
Assert.Same(
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address1)),
ServicePointManager.FindServicePoint(address2, new FixedWebProxy(address1)));
Assert.Same(
ServicePointManager.FindServicePoint(Localhost, new FixedWebProxy(address1)),
ServicePointManager.FindServicePoint(Localhost, new FixedWebProxy(address2)));
Assert.NotSame(
ServicePointManager.FindServicePoint(address1, null),
ServicePointManager.FindServicePoint(address2, null));
Assert.NotSame(
ServicePointManager.FindServicePoint(address1, null),
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address1)));
Assert.NotSame(
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address1)),
ServicePointManager.FindServicePoint(address1, new FixedWebProxy(address2)));
}
[Fact]
public static void FindServicePoint_Collectible()
{
string address = "http://" + Guid.NewGuid().ToString("N");
bool initial = GetExpect100Continue(address);
SetExpect100Continue(address, !initial);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Assert.Equal(initial, GetExpect100Continue(address));
}
[Fact]
public static void FindServicePoint_ReturnedServicePointMatchesExpectedValues()
{
string address = "http://" + Guid.NewGuid().ToString("N");
DateTime start = DateTime.Now;
ServicePoint sp = ServicePointManager.FindServicePoint(address, null);
Assert.InRange(sp.IdleSince, start, DateTime.MaxValue);
Assert.Equal(new Uri(address), sp.Address);
Assert.Null(sp.BindIPEndPointDelegate);
Assert.Null(sp.Certificate);
Assert.Null(sp.ClientCertificate);
Assert.Equal(-1, sp.ConnectionLeaseTimeout);
Assert.Equal("http", sp.ConnectionName);
Assert.Equal(0, sp.CurrentConnections);
Assert.Equal(true, sp.Expect100Continue);
Assert.Equal(100000, sp.MaxIdleTime);
Assert.Equal(new Version(1, 1), sp.ProtocolVersion);
Assert.Equal(-1, sp.ReceiveBufferSize);
Assert.True(sp.SupportsPipelining, "SupportsPipelining");
Assert.True(sp.UseNagleAlgorithm, "UseNagleAlgorithm");
}
[Fact]
public static void FindServicePoint_PropertiesRoundtrip()
{
string address = "http://" + Guid.NewGuid().ToString("N");
BindIPEndPoint expectedBindIPEndPointDelegate = delegate { return null; };
int expectedConnectionLeaseTimeout = 42;
int expectedConnectionLimit = 84;
bool expected100Continue = false;
int expectedMaxIdleTime = 200000;
int expectedReceiveBufferSize = 123;
bool expectedUseNagleAlgorithm = false;
ServicePoint sp1 = ServicePointManager.FindServicePoint(address, null);
sp1.BindIPEndPointDelegate = expectedBindIPEndPointDelegate;
sp1.ConnectionLeaseTimeout = expectedConnectionLeaseTimeout;
sp1.ConnectionLimit = expectedConnectionLimit;
sp1.Expect100Continue = expected100Continue;
sp1.MaxIdleTime = expectedMaxIdleTime;
sp1.ReceiveBufferSize = expectedReceiveBufferSize;
sp1.UseNagleAlgorithm = expectedUseNagleAlgorithm;
ServicePoint sp2 = ServicePointManager.FindServicePoint(address, null);
Assert.Same(expectedBindIPEndPointDelegate, sp2.BindIPEndPointDelegate);
Assert.Equal(expectedConnectionLeaseTimeout, sp2.ConnectionLeaseTimeout);
Assert.Equal(expectedConnectionLimit, sp2.ConnectionLimit);
Assert.Equal(expected100Continue, sp2.Expect100Continue);
Assert.Equal(expectedMaxIdleTime, sp2.MaxIdleTime);
Assert.Equal(expectedReceiveBufferSize, sp2.ReceiveBufferSize);
Assert.Equal(expectedUseNagleAlgorithm, sp2.UseNagleAlgorithm);
}
[Fact]
public static void FindServicePoint_NewServicePointsInheritCurrentValues()
{
string address1 = "http://" + Guid.NewGuid().ToString("N");
string address2 = "http://" + Guid.NewGuid().ToString("N");
bool orig100Continue = ServicePointManager.Expect100Continue;
bool origNagle = ServicePointManager.UseNagleAlgorithm;
ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false;
ServicePoint sp1 = ServicePointManager.FindServicePoint(address1, null);
Assert.False(sp1.Expect100Continue);
Assert.False(sp1.UseNagleAlgorithm);
ServicePointManager.Expect100Continue = true;
ServicePointManager.UseNagleAlgorithm = true;
ServicePoint sp2 = ServicePointManager.FindServicePoint(address2, null);
Assert.True(sp2.Expect100Continue);
Assert.True(sp2.UseNagleAlgorithm);
Assert.False(sp1.Expect100Continue);
Assert.False(sp1.UseNagleAlgorithm);
ServicePointManager.Expect100Continue = orig100Continue;
ServicePointManager.UseNagleAlgorithm = origNagle;
}
// Separated out to avoid the JIT in debug builds interfering with object lifetimes
private static bool GetExpect100Continue(string address) =>
ServicePointManager.FindServicePoint(address, null).Expect100Continue;
private static void SetExpect100Continue(string address, bool value) =>
ServicePointManager.FindServicePoint(address, null).Expect100Continue = value;
private sealed class FixedWebProxy : IWebProxy
{
private readonly Uri _proxyAddress;
public FixedWebProxy(string proxyAddress) { _proxyAddress = new Uri(proxyAddress); }
public Uri GetProxy(Uri destination) => _proxyAddress;
public bool IsBypassed(Uri host) => false;
public ICredentials Credentials { get; set; }
}
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Net.ServicePoint.Tests.csproj">
<TargetGroup>netstandard</TargetGroup>
<TestTFMs>netcoreapp</TestTFMs>
</Project>
<Project Include="System.Net.ServicePoint.Tests.csproj">
<TargetGroup>netcoreapp</TargetGroup>
<!-- TODO #13070: Add net463 once the TFM is actually .Net 4.6.3 -->
<TestTFMs>netcoreapp</TestTFMs>
</Project>
<Project Include="System.Net.ServicePoint.Tests.csproj">
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>net462</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{0D1E2954-A5C7-4B8C-932A-31EB4A96A726}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="ServicePointManagerTest.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'">
<!-- TODO #13070: Add net463 to the condition after the TFM gets updated to the actual .Net 4.6.3.-->
<Compile Include="TlsSystemDefault.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,23 @@
// 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 Xunit;
namespace System.Net.Tests
{
public class TlsSystemDefault
{
[Fact]
public void ServicePointManager_SecurityProtocolDefault_Ok()
{
Assert.Equal(SecurityProtocolType.SystemDefault, ServicePointManager.SecurityProtocol);
}
[Fact]
public void ServicePointManager_CheckAllowedProtocols_SystemDefault_Allowed()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault;
}
}
}