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,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.WebHeaderCollection.Tests", "tests\System.Net.WebHeaderCollection.Tests.csproj", "{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}"
ProjectSection(ProjectDependencies) = postProject
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F} = {5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.WebHeaderCollection", "src\System.Net.WebHeaderCollection.csproj", "{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU
DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU = DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU
ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU = ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnetcoreappnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.DebugNETCoreAppnetcoreappnetcoreapp|AnyCPU.Build.0 = netcoreapp-Debug|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU.ActiveCfg = netcoreapp-Release|Any CPU
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.ReleaseNETCoreAppnetcoreappnetcoreapp|AnyCPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
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.1.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,126 @@
// 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 enum HttpRequestHeader
{
Accept = 20,
AcceptCharset = 21,
AcceptEncoding = 22,
AcceptLanguage = 23,
Allow = 10,
Authorization = 24,
CacheControl = 0,
Connection = 1,
ContentEncoding = 13,
ContentLanguage = 14,
ContentLength = 11,
ContentLocation = 15,
ContentMd5 = 16,
ContentRange = 17,
ContentType = 12,
Cookie = 25,
Date = 2,
Expect = 26,
Expires = 18,
From = 27,
Host = 28,
IfMatch = 29,
IfModifiedSince = 30,
IfNoneMatch = 31,
IfRange = 32,
IfUnmodifiedSince = 33,
KeepAlive = 3,
LastModified = 19,
MaxForwards = 34,
Pragma = 4,
ProxyAuthorization = 35,
Range = 37,
Referer = 36,
Te = 38,
Trailer = 5,
TransferEncoding = 6,
Translate = 39,
Upgrade = 7,
UserAgent = 40,
Via = 8,
Warning = 9,
}
public enum HttpResponseHeader
{
AcceptRanges = 20,
Age = 21,
Allow = 10,
CacheControl = 0,
Connection = 1,
ContentEncoding = 13,
ContentLanguage = 14,
ContentLength = 11,
ContentLocation = 15,
ContentMd5 = 16,
ContentRange = 17,
ContentType = 12,
Date = 2,
ETag = 22,
Expires = 18,
KeepAlive = 3,
LastModified = 19,
Location = 23,
Pragma = 4,
ProxyAuthenticate = 24,
RetryAfter = 25,
Server = 26,
SetCookie = 27,
Trailer = 5,
TransferEncoding = 6,
Upgrade = 7,
Vary = 28,
Via = 8,
Warning = 9,
WwwAuthenticate = 29,
}
public partial class WebHeaderCollection : System.Collections.Specialized.NameValueCollection,
System.Collections.IEnumerable, System.Runtime.Serialization.ISerializable
{
public WebHeaderCollection() { }
public override string[] AllKeys { get { throw null; } }
public override int Count { get { throw null; } }
public string this[System.Net.HttpRequestHeader header] { get { throw null; } set { } }
public string this[System.Net.HttpResponseHeader header] { get { throw null; } set { } }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public override string ToString() { throw null; }
protected WebHeaderCollection(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public new string this[string name] { get { throw null; } set { } }
public override System.Collections.IEnumerator GetEnumerator() { throw null; }
public override void Remove(string name) { }
public byte[] ToByteArray() { throw null; }
public static bool IsRestricted(string headerName, bool response) { throw null; }
public static bool IsRestricted(string headerName) { throw null; }
public override void OnDeserialization(object sender) { }
public void Remove(HttpResponseHeader header) { }
public void Remove(HttpRequestHeader header) { }
public override string[] GetValues(int index) { throw null; }
public override string[] GetValues(string header) { throw null; }
public override string GetKey(int index) { throw null; }
public override void Clear() { }
public override string Get(int index) { throw null; }
public override string Get(string name) { throw null; }
public void Set(HttpRequestHeader header, string value) { }
public void Set(HttpResponseHeader header, string value) { }
public override void Set(string name, string value) { }
public void Add(HttpRequestHeader header, string value) { }
public void Add(HttpResponseHeader header, string value) { }
public void Add(string header) { }
public override void Add(string name, string value) { }
protected void AddWithoutValidate(string headerName, string headerValue) { }
public override System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys { get { throw null; } }
}
}

View File

@ -0,0 +1,16 @@
<?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.WebHeaderCollection.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Collections.Specialized\ref\System.Collections.Specialized.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</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>
net463-Windows_NT;
netcoreapp;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,147 @@
<?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_headers_req" xml:space="preserve">
<value>This collection holds response headers and cannot contain the specified request header.</value>
</data>
<data name="net_headers_rsp" xml:space="preserve">
<value>This collection holds request headers and cannot contain the specified response header.</value>
</data>
<data name="net_WebHeaderInvalidControlChars" xml:space="preserve">
<value>Specified value has invalid Control characters.</value>
</data>
<data name="net_WebHeaderInvalidCRLFChars" xml:space="preserve">
<value>Specified value has invalid CRLF characters.</value>
</data>
<data name="net_WebHeaderInvalidHeaderChars" xml:space="preserve">
<value>Specified value has invalid HTTP Header characters.</value>
</data>
<data name="net_WebHeaderInvalidNonAsciiChars" xml:space="preserve">
<value>Specified value has invalid non-ASCII characters.</value>
</data>
<data name="net_headers_toolong" xml:space="preserve">
<value>Header values cannot be longer than {0} characters.</value>
</data>
<data name="net_WebHeaderMissingColon" xml:space="preserve">
<value>Specified value does not have a ':' separator.</value>
</data>
<data name="net_headerrestrict" xml:space="preserve">
<value>The {0} header must be modified using the appropriate property or method.</value>
</data>
</root>

View File

@ -0,0 +1,55 @@
<?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>{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}</ProjectGuid>
<AssemblyName>System.Net.WebHeaderCollection</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'net463'">true</IsPartialFacadeAssembly>
<ResourcesSourceOutputDirectory Condition="'$(TargetGroup)' == 'net463'">None</ResourcesSourceOutputDirectory>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="System\Net\WebHeaderCollection.cs" />
<Compile Include="System\Net\HttpResponseHeader.cs" />
<Compile Include="System\Net\HttpRequestHeader.cs" />
<Compile Include="System\Net\HeaderInfo.cs" />
<Compile Include="System\Net\HeaderInfoTable.cs" />
<Compile Include="System\Net\NetEventSource.WebHeaderCollection.cs" />
<Compile Include="$(CommonPath)\System\Net\CaseInsensitiveAscii.cs">
<Link>Common\System\Net\CaseInsensitiveAscii.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\StringExtensions.cs">
<Link>Common\System\StringExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>Common\System\Net\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpValidationHelpers.cs">
<Link>Common\System\Net\HttpValidationHelpers.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\InternalException.cs">
<Link>Common\System\Net\InternalException.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.Common.cs">
<Link>Common\System\Net\Logging\NetEventSource.Common.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'net463'">
<TargetingPackReference Include="mscorlib" />
<TargetingPackReference Include="System" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections.Specialized" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@ -0,0 +1,24 @@
// 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.
internal class HeaderInfo
{
internal readonly bool IsRequestRestricted;
internal readonly bool IsResponseRestricted;
//
// Note that the HeaderName field is not always valid, and should not
// be used after initialization. In particular, the HeaderInfo returned
// for an unknown header will not have the correct header name.
//
internal readonly string HeaderName;
internal readonly bool AllowMultiValues;
internal HeaderInfo(string name, bool requestRestricted, bool responseRestricted, bool multi)
{
HeaderName = name;
IsRequestRestricted = requestRestricted;
IsResponseRestricted = responseRestricted;
AllowMultiValues = multi;
}
}

View File

@ -0,0 +1,93 @@
// 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;
using System.Collections.Specialized;
namespace System.Net
{
internal class HeaderInfoTable
{
private static Hashtable HeaderHashTable;
private static HeaderInfo UnknownHeaderInfo = new HeaderInfo(string.Empty, false, false, false);
static HeaderInfoTable()
{
HeaderInfo[] InfoArray = new HeaderInfo[]
{
new HeaderInfo(HttpKnownHeaderNames.Age, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Allow, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Accept, true, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Authorization, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.AcceptRanges, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.AcceptCharset, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.AcceptEncoding, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.AcceptLanguage, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Cookie, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Connection, true, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ContentMD5, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.ContentType, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.CacheControl, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ContentRange, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.ContentLength, true, true, false ),
new HeaderInfo(HttpKnownHeaderNames.ContentEncoding, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ContentLanguage, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ContentLocation, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Date, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.ETag, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Expect, true, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Expires, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.From, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Host, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.IfMatch, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.IfRange, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.IfNoneMatch, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.IfModifiedSince, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.IfUnmodifiedSince, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.KeepAlive, false, true, false ),
new HeaderInfo(HttpKnownHeaderNames.Location, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.LastModified, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.MaxForwards, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Pragma, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ProxyAuthenticate, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ProxyAuthorization, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.ProxyConnection, true, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Range, true, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Referer, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.RetryAfter, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Server, false, false, false ),
new HeaderInfo(HttpKnownHeaderNames.SetCookie, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.SetCookie2, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.TE, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Trailer, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.TransferEncoding, true, true, true ),
new HeaderInfo(HttpKnownHeaderNames.Upgrade, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.UserAgent, true, false, false ),
new HeaderInfo(HttpKnownHeaderNames.Via, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Vary, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.Warning, false, false, true ),
new HeaderInfo(HttpKnownHeaderNames.WWWAuthenticate, false, true, true ),
};
HeaderHashTable = new Hashtable(InfoArray.Length * 2, CaseInsensitiveAscii.StaticInstance);
for (int i = 0; i < InfoArray.Length; i++)
{
HeaderHashTable[InfoArray[i].HeaderName] = InfoArray[i];
}
}
internal HeaderInfo this[string name]
{
get
{
HeaderInfo tempHeaderInfo = (HeaderInfo)HeaderHashTable[name];
if (tempHeaderInfo == null)
{
return UnknownHeaderInfo;
}
return tempHeaderInfo;
}
}
}
}

View File

@ -0,0 +1,104 @@
// 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 enum HttpRequestHeader
{
CacheControl = 0, // general-header [section 4.5]
Connection = 1, // general-header [section 4.5]
Date = 2, // general-header [section 4.5]
KeepAlive = 3, // general-header [not in RFC]
Pragma = 4, // general-header [section 4.5]
Trailer = 5, // general-header [section 4.5]
TransferEncoding = 6, // general-header [section 4.5]
Upgrade = 7, // general-header [section 4.5]
Via = 8, // general-header [section 4.5]
Warning = 9, // general-header [section 4.5]
Allow = 10, // entity-header [section 7.1]
ContentLength = 11, // entity-header [section 7.1]
ContentType = 12, // entity-header [section 7.1]
ContentEncoding = 13, // entity-header [section 7.1]
ContentLanguage = 14, // entity-header [section 7.1]
ContentLocation = 15, // entity-header [section 7.1]
ContentMd5 = 16, // entity-header [section 7.1]
ContentRange = 17, // entity-header [section 7.1]
Expires = 18, // entity-header [section 7.1]
LastModified = 19, // entity-header [section 7.1]
Accept = 20, // request-header [section 5.3]
AcceptCharset = 21, // request-header [section 5.3]
AcceptEncoding = 22, // request-header [section 5.3]
AcceptLanguage = 23, // request-header [section 5.3]
Authorization = 24, // request-header [section 5.3]
Cookie = 25, // request-header [not in RFC]
Expect = 26, // request-header [section 5.3]
From = 27, // request-header [section 5.3]
Host = 28, // request-header [section 5.3]
IfMatch = 29, // request-header [section 5.3]
IfModifiedSince = 30, // request-header [section 5.3]
IfNoneMatch = 31, // request-header [section 5.3]
IfRange = 32, // request-header [section 5.3]
IfUnmodifiedSince = 33, // request-header [section 5.3]
MaxForwards = 34, // request-header [section 5.3]
ProxyAuthorization = 35, // request-header [section 5.3]
Referer = 36, // request-header [section 5.3]
Range = 37, // request-header [section 5.3]
Te = 38, // request-header [section 5.3]
Translate = 39, // request-header [webDAV, not in RFC 2518]
UserAgent = 40, // request-header [section 5.3]
}
internal static class HttpRequestHeaderExtensions
{
private static readonly string[] s_names = {
"Cache-Control",
"Connection",
"Date",
"Keep-Alive",
"Pragma",
"Trailer",
"Transfer-Encoding",
"Upgrade",
"Via",
"Warning",
"Allow",
"Content-Length",
"Content-Type",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Expires",
"Last-Modified",
"Accept",
"Accept-Charset",
"Accept-Encoding",
"Accept-Language",
"Authorization",
"Cookie",
"Expect",
"From",
"Host",
"If-Match",
"If-Modified-Since",
"If-None-Match",
"If-Range",
"If-Unmodified-Since",
"Max-Forwards",
"Proxy-Authorization",
"Referer",
"Range",
"Te",
"Translate",
"User-Agent",
};
public static string GetName(this HttpRequestHeader header)
{
return s_names[(int)header];
}
}
}

View File

@ -0,0 +1,82 @@
// 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 enum HttpResponseHeader
{
CacheControl = 0, // general-header [section 4.5]
Connection = 1, // general-header [section 4.5]
Date = 2, // general-header [section 4.5]
KeepAlive = 3, // general-header [not in RFC]
Pragma = 4, // general-header [section 4.5]
Trailer = 5, // general-header [section 4.5]
TransferEncoding = 6, // general-header [section 4.5]
Upgrade = 7, // general-header [section 4.5]
Via = 8, // general-header [section 4.5]
Warning = 9, // general-header [section 4.5]
Allow = 10, // entity-header [section 7.1]
ContentLength = 11, // entity-header [section 7.1]
ContentType = 12, // entity-header [section 7.1]
ContentEncoding = 13, // entity-header [section 7.1]
ContentLanguage = 14, // entity-header [section 7.1]
ContentLocation = 15, // entity-header [section 7.1]
ContentMd5 = 16, // entity-header [section 7.1]
ContentRange = 17, // entity-header [section 7.1]
Expires = 18, // entity-header [section 7.1]
LastModified = 19, // entity-header [section 7.1]
AcceptRanges = 20, // response-header [section 6.2]
Age = 21, // response-header [section 6.2]
ETag = 22, // response-header [section 6.2]
Location = 23, // response-header [section 6.2]
ProxyAuthenticate = 24, // response-header [section 6.2]
RetryAfter = 25, // response-header [section 6.2]
Server = 26, // response-header [section 6.2]
SetCookie = 27, // response-header [not in RFC]
Vary = 28, // response-header [section 6.2]
WwwAuthenticate = 29, // response-header [section 6.2]
}
internal static class HttpResponseHeaderExtensions
{
private static readonly string[] s_names = {
"Cache-Control",
"Connection",
"Date",
"Keep-Alive",
"Pragma",
"Trailer",
"Transfer-Encoding",
"Upgrade",
"Via",
"Warning",
"Allow",
"Content-Length",
"Content-Type",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Expires",
"Last-Modified",
"Accept-Ranges",
"Age",
"ETag",
"Location",
"Proxy-Authenticate",
"Retry-After",
"Server",
"Set-Cookie",
"Vary",
"WWW-Authenticate",
};
public static string GetName(this HttpResponseHeader header)
{
return s_names[(int)header];
}
}
}

View File

@ -0,0 +1,11 @@
// 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.Tracing;
namespace System.Net
{
[EventSource(Name = "Microsoft-System-Net-WebHeaderCollection")]
internal sealed partial class NetEventSource { }
}

View File

@ -0,0 +1,495 @@
// 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text;
namespace System.Net
{
internal enum WebHeaderCollectionType : byte
{
Unknown,
WebRequest,
WebResponse,
HttpWebRequest,
HttpWebResponse,
HttpListenerRequest,
HttpListenerResponse,
FtpWebRequest,
FtpWebResponse,
FileWebRequest,
FileWebResponse,
}
[Serializable]
public class WebHeaderCollection : NameValueCollection, ISerializable
{
private const int ApproxAveHeaderLineSize = 30;
private const int ApproxHighAvgNumHeaders = 16;
private WebHeaderCollectionType _type;
private NameValueCollection _innerCollection;
private static HeaderInfoTable _headerInfo;
protected WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
int count = serializationInfo.GetInt32("Count");
for (int i = 0; i < count; i++)
{
string headerName = serializationInfo.GetString(i.ToString(NumberFormatInfo.InvariantInfo));
string headerValue = serializationInfo.GetString((i + count).ToString(NumberFormatInfo.InvariantInfo));
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{headerName}], value:[{headerValue}]");
InnerCollection.Add(headerName, headerValue);
}
}
private bool AllowHttpRequestHeader
{
get
{
if (_type == WebHeaderCollectionType.Unknown)
{
_type = WebHeaderCollectionType.WebRequest;
}
return _type == WebHeaderCollectionType.WebRequest ||
_type == WebHeaderCollectionType.HttpWebRequest ||
_type == WebHeaderCollectionType.HttpListenerRequest;
}
}
private static HeaderInfoTable HeaderInfo
{
get
{
if (_headerInfo == null)
{
_headerInfo = new HeaderInfoTable();
}
return _headerInfo;
}
}
private NameValueCollection InnerCollection
{
get
{
if (_innerCollection == null)
_innerCollection = new NameValueCollection(ApproxHighAvgNumHeaders, CaseInsensitiveAscii.StaticInstance);
return _innerCollection;
}
}
private bool AllowHttpResponseHeader
{
get
{
if (_type == WebHeaderCollectionType.Unknown)
{
_type = WebHeaderCollectionType.WebResponse;
}
return _type == WebHeaderCollectionType.WebResponse ||
_type == WebHeaderCollectionType.HttpWebResponse ||
_type == WebHeaderCollectionType.HttpListenerResponse;
}
}
public string this[HttpRequestHeader header]
{
get
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
return this[header.GetName()];
}
set
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
this[header.GetName()] = value;
}
}
public string this[HttpResponseHeader header]
{
get
{
if (!AllowHttpResponseHeader)
{
throw new InvalidOperationException(SR.net_headers_rsp);
}
return this[header.GetName()];
}
set
{
if (!AllowHttpResponseHeader)
{
throw new InvalidOperationException(SR.net_headers_rsp);
}
this[header.GetName()] = value;
}
}
public override void Set(string name, string value)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
ThrowOnRestrictedHeader(name);
value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Set() key:[{name}], value:[{value}]");
if (_type == WebHeaderCollectionType.WebResponse)
{
if (value != null && value.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture,SR.net_headers_toolong, ushort.MaxValue));
}
}
InvalidateCachedArrays();
InnerCollection.Set(name, value);
}
public void Set(HttpRequestHeader header, string value)
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
this.Set(header.GetName(), value);
}
public void Set(HttpResponseHeader header, string value)
{
if (!AllowHttpResponseHeader)
{
throw new InvalidOperationException(SR.net_headers_rsp);
}
if (_type == WebHeaderCollectionType.WebResponse)
{
if (value != null && value.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
}
}
this.Set(header.GetName(), value);
}
public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
//
// for now disregard streamingContext.
//
serializationInfo.AddValue("Count", Count);
for (int i = 0; i < Count; i++)
{
serializationInfo.AddValue(i.ToString(NumberFormatInfo.InvariantInfo), GetKey(i));
serializationInfo.AddValue((i + Count).ToString(NumberFormatInfo.InvariantInfo), Get(i));
}
}
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
GetObjectData(serializationInfo, streamingContext);
}
public void Remove(HttpRequestHeader header)
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
this.Remove(header.GetName());
}
public void Remove(HttpResponseHeader header)
{
if (!AllowHttpResponseHeader)
{
throw new InvalidOperationException(SR.net_headers_rsp);
}
this.Remove(header.GetName());
}
public override void OnDeserialization(object sender)
{
// Nop in desktop
}
public static bool IsRestricted(string headerName)
{
return IsRestricted(headerName, false);
}
public static bool IsRestricted(string headerName, bool response)
{
headerName = HttpValidationHelpers.CheckBadHeaderNameChars(headerName);
return response ? HeaderInfo[headerName].IsResponseRestricted : HeaderInfo[headerName].IsRequestRestricted;
}
public override string[] GetValues(int index)
{
return InnerCollection.GetValues(index);
}
public override string[] GetValues(string header)
{
return InnerCollection.GetValues(header);
}
public override string GetKey(int index)
{
return InnerCollection.GetKey(index);
}
public override void Clear()
{
InvalidateCachedArrays();
if (_innerCollection != null)
{
_innerCollection.Clear();
}
}
public override string Get(int index)
{
if (_innerCollection == null)
{
return null;
}
return _innerCollection.Get(index);
}
public override string Get(string name)
{
if (_innerCollection == null)
{
return null;
}
return _innerCollection.Get(name);
}
public void Add(HttpRequestHeader header, string value)
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
this.Add(header.GetName(), value);
}
public void Add(HttpResponseHeader header, string value)
{
if (!AllowHttpResponseHeader)
{
throw new InvalidOperationException(SR.net_headers_rsp);
}
if (_type == WebHeaderCollectionType.WebResponse)
{
if (value != null && value.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
}
}
this.Add(header.GetName(), value);
}
public void Add(string header)
{
if (string.IsNullOrWhiteSpace(header))
{
throw new ArgumentNullException(nameof(header));
}
int colpos = header.IndexOf(':');
// check for badly formed header passed in
if (colpos < 0)
{
throw new ArgumentException(SR.net_WebHeaderMissingColon, nameof(header));
}
string name = header.Substring(0, colpos);
string value = header.Substring(colpos + 1);
name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
ThrowOnRestrictedHeader(name);
value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Add({header}) calling InnerCollection.Add() key:[{name}], value:[{value}]");
if (_type == WebHeaderCollectionType.WebResponse)
{
if (value != null && value.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
}
}
InvalidateCachedArrays();
InnerCollection.Add(name, value);
}
public override void Add(string name, string value)
{
name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
ThrowOnRestrictedHeader(name);
value = HttpValidationHelpers.CheckBadHeaderValueChars(value);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{name}], value:[{value}]");
if (_type == WebHeaderCollectionType.WebResponse)
{
if (value != null && value.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(value), value,string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
}
}
InvalidateCachedArrays();
InnerCollection.Add(name, value);
}
protected void AddWithoutValidate(string headerName, string headerValue)
{
headerName = HttpValidationHelpers.CheckBadHeaderNameChars(headerName);
headerValue = HttpValidationHelpers.CheckBadHeaderValueChars(headerValue);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Add() key:[{headerName}], value:[{headerValue}]");
if (_type == WebHeaderCollectionType.WebResponse)
{
if (headerValue != null && headerValue.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(headerValue), headerValue, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
}
}
InvalidateCachedArrays();
InnerCollection.Add(headerName, headerValue);
}
internal void ThrowOnRestrictedHeader(string headerName)
{
if (_type == WebHeaderCollectionType.HttpWebRequest)
{
if (HeaderInfo[headerName].IsRequestRestricted)
{
throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
}
}
else if (_type == WebHeaderCollectionType.HttpListenerResponse)
{
if (HeaderInfo[headerName].IsResponseRestricted)
{
throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
}
}
}
// Remove -
// Routine Description:
// Removes give header with validation to see if they are "proper" headers.
// If the header is a special header, listed in RestrictedHeaders object,
// then this call will cause an exception indicating as such.
// Arguments:
// name - header-name to remove
// Return Value:
// None
/// <devdoc>
/// <para>Removes the specified header.</para>
/// </devdoc>
public override void Remove(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}
ThrowOnRestrictedHeader(name);
name = HttpValidationHelpers.CheckBadHeaderNameChars(name);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"calling InnerCollection.Remove() key:[{name}]");
if (_innerCollection != null)
{
InvalidateCachedArrays();
_innerCollection.Remove(name);
}
}
// ToString() -
// Routine Description:
// Generates a string representation of the headers, that is ready to be sent except for it being in string format:
// the format looks like:
//
// Header-Name: Header-Value\r\n
// Header-Name2: Header-Value2\r\n
// ...
// Header-NameN: Header-ValueN\r\n
// \r\n
//
// Uses the string builder class to Append the elements together.
// Arguments:
// None.
// Return Value:
// string
public override string ToString()
{
if (Count == 0)
{
return "\r\n";
}
var sb = new StringBuilder(ApproxAveHeaderLineSize * Count);
foreach (string key in InnerCollection)
{
string val = InnerCollection.Get(key);
sb.Append(key)
.Append(": ")
.Append(val)
.Append("\r\n");
}
sb.Append("\r\n");
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"ToString: {sb}");
return sb.ToString();
}
public byte[] ToByteArray()
{
string tempString = this.ToString();
return System.Text.Encoding.ASCII.GetBytes(tempString);
}
public WebHeaderCollection()
{
}
public override int Count
{
get
{
return (_innerCollection == null ? 0 : _innerCollection.Count);
}
}
public override KeysCollection Keys
{
get
{
return InnerCollection.Keys;
}
}
public override string[] AllKeys
{
get
{
return InnerCollection.AllKeys;
}
}
public override IEnumerator GetEnumerator()
{
return InnerCollection.Keys.GetEnumerator();
}
}
}

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>
netstandard1.3-Windows_NT;
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,24 @@
// 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.Tracing;
using Xunit;
namespace System.Net.Tests
{
public class LoggingTest
{
[Fact]
public void EventSource_ExistsWithCorrectId()
{
Type esType = typeof(WebHeaderCollection).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false);
Assert.NotNull(esType);
Assert.Equal("Microsoft-System-Net-WebHeaderCollection", EventSource.GetName(esType));
Assert.Equal(Guid.Parse("fd36452f-9f2b-5850-d212-6c436231e3dc"), EventSource.GetGuid(esType));
Assert.NotEmpty(EventSource.GenerateManifest(esType, esType.Assembly.Location));
}
}
}

View File

@ -0,0 +1,17 @@
<?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.WebHeaderCollection.Tests.csproj" />
<Project Include="System.Net.WebHeaderCollection.Tests.csproj">
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>net463</TestTFMs>
</Project>
<Project Include="System.Net.WebHeaderCollection.Tests.csproj">
<TargetGroup>netstandard1.3</TargetGroup>
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>netcore50;net46;netcoreapp1.0</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@ -0,0 +1,23 @@
<?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>{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}</ProjectGuid>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="WebHeaderCollectionTest.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<Compile Include="LoggingTest.cs" />
<Compile Include="WebHeaderCollectionTest.netstandard.cs" />
<Compile Include="$(CommonTestPath)\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs">
<Link>Common\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@ -0,0 +1,391 @@
// 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;
using Xunit;
namespace System.Net.WebHeaderCollectionTests
{
public partial class WebHeaderCollectionTest
{
[Fact]
public void Ctor_Success()
{
new WebHeaderCollection();
}
[Fact]
public void DefaultPropertyValues_ReturnEmptyAfterConstruction_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Equal(0, w.AllKeys.Length);
Assert.Equal(0, w.Count);
Assert.Equal("\r\n", w.ToString());
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
[Fact]
public void HttpRequestHeader_Add_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Connection] = "keep-alive";
Assert.Equal(1, w.Count);
Assert.Equal("keep-alive", w[HttpRequestHeader.Connection]);
Assert.Equal("Connection", w.AllKeys[0]);
}
[Theory]
[InlineData((HttpRequestHeader)int.MinValue)]
[InlineData((HttpRequestHeader)(-1))]
[InlineData((HttpRequestHeader)int.MaxValue)]
public void HttpRequestHeader_AddInvalid_Throws(HttpRequestHeader header)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<IndexOutOfRangeException>(() => w[header] = "foo");
}
[Theory]
[InlineData((HttpResponseHeader)int.MinValue)]
[InlineData((HttpResponseHeader)(-1))]
[InlineData((HttpResponseHeader)int.MaxValue)]
public void HttpResponseHeader_AddInvalid_Throws(HttpResponseHeader header)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<IndexOutOfRangeException>(() => w[header] = "foo");
}
[Fact]
public void CustomHeader_AddQuery_Success()
{
string customHeader = "Custom-Header";
string customValue = "Custom;.-Value";
WebHeaderCollection w = new WebHeaderCollection();
w[customHeader] = customValue;
Assert.Equal(1, w.Count);
Assert.Equal(customValue, w[customHeader]);
Assert.Equal(customHeader, w.AllKeys[0]);
}
[Fact]
public void HttpResponseHeader_AddQuery_CommonHeader_Success()
{
string headerValue = "value123";
WebHeaderCollection w = new WebHeaderCollection();
w[HttpResponseHeader.ProxyAuthenticate] = headerValue;
w[HttpResponseHeader.WwwAuthenticate] = headerValue;
Assert.Equal(headerValue, w[HttpResponseHeader.ProxyAuthenticate]);
Assert.Equal(headerValue, w[HttpResponseHeader.WwwAuthenticate]);
}
[Fact]
public void HttpRequest_AddQuery_CommonHeader_Success()
{
string headerValue = "value123";
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Accept] = headerValue;
Assert.Equal(headerValue, w[HttpRequestHeader.Accept]);
}
[Fact]
public void RequestThenResponseHeaders_Add_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Accept] = "text/json";
Assert.Throws<InvalidOperationException>(() => w[HttpResponseHeader.ContentLength] = "123");
}
[Fact]
public void ResponseThenRequestHeaders_Add_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpResponseHeader.ContentLength] = "123";
Assert.Throws<InvalidOperationException>(() => w[HttpRequestHeader.Accept] = "text/json");
}
[Fact]
public void ResponseHeader_QueryRequest_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpResponseHeader.ContentLength] = "123";
Assert.Throws<InvalidOperationException>(() => w[HttpRequestHeader.Accept]);
}
[Fact]
public void RequestHeader_QueryResponse_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Accept] = "text/json";
Assert.Throws<InvalidOperationException>(() => w[HttpResponseHeader.ContentLength]);
}
[Fact]
public void Setter_ValidName_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w["Accept"] = "text/json";
}
[Theory]
[InlineData(null)]
[InlineData("")]
public void Setter_NullOrEmptyName_Throws(string name)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>("name", () => w[name] = "test");
}
public static object[][] InvalidNames = {
new object[] { "(" },
new object[] { "\u1234" },
new object[] { "\u0019" }
};
[Theory, MemberData(nameof(InvalidNames))]
public void Setter_InvalidName_Throws(string name)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>("name", () => w[name] = "test");
}
public static object[][] InvalidValues = {
new object[] { "value1\rvalue2\r" },
new object[] { "value1\nvalue2\r" },
new object[] { "value1\u007fvalue2" },
new object[] { "value1\r\nvalue2" },
new object[] { "value1\u0019value2" }
};
[Theory, MemberData(nameof(InvalidValues))]
public void Setter_InvalidValue_Throws(string value)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>("value", () => w["custom"] = value);
}
public static object[][] ValidValues = {
new object[] { null },
new object[] { "" },
new object[] { "value1\r\n" },
new object[] { "value1\tvalue2" },
new object[] { "value1\r\n\tvalue2" },
new object[] { "value1\r\n value2" }
};
[Theory, MemberData(nameof(ValidValues))]
public void Setter_ValidValue_Success(string value)
{
WebHeaderCollection w = new WebHeaderCollection();
w["custom"] = value;
}
[Theory]
[InlineData("name", "name")]
[InlineData("name", "NaMe")]
[InlineData("nAmE", "name")]
public void Setter_SameHeaderTwice_Success(string firstName, string secondName)
{
WebHeaderCollection w = new WebHeaderCollection();
w[firstName] = "first";
w[secondName] = "second";
Assert.Equal(1, w.Count);
Assert.NotEmpty(w);
Assert.NotEmpty(w.AllKeys);
Assert.Equal(new[] { firstName }, w.AllKeys);
Assert.Equal("second", w[firstName]);
Assert.Equal("second", w[secondName]);
}
[Theory]
[InlineData(null)]
[InlineData("")]
public void Remove_NullOrEmptyName_Throws(string name)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>("name", () => w.Remove(name));
}
[Fact]
public void Remove_IllegalCharacter_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>("name", () => w.Remove("{"));
}
[Fact]
public void Remove_EmptyCollection_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Remove("foo");
Assert.Equal(0, w.Count);
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
[Theory]
[InlineData("name", "name")]
[InlineData("name", "NaMe")]
public void Remove_SetThenRemove_Success(string setName, string removeName)
{
WebHeaderCollection w = new WebHeaderCollection();
w[setName] = "value";
w.Remove(removeName);
Assert.Equal(0, w.Count);
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
[Theory]
[InlineData("name", "name")]
[InlineData("name", "NaMe")]
public void Remove_SetTwoThenRemoveOne_Success(string setName, string removeName)
{
WebHeaderCollection w = new WebHeaderCollection();
w[setName] = "value";
w["foo"] = "bar";
w.Remove(removeName);
Assert.Equal(1, w.Count);
Assert.NotEmpty(w);
Assert.NotEmpty(w.AllKeys);
Assert.Equal(new[] { "foo" }, w.AllKeys);
Assert.Equal("bar", w["foo"]);
}
[Fact]
public void Getter_EmptyCollection_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Null(w["name"]);
Assert.Equal(0, w.Count);
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
[Fact]
public void Getter_NonEmptyCollectionNonExistentHeader_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w["name"] = "value";
Assert.Null(w["foo"]);
Assert.Equal(1, w.Count);
Assert.NotEmpty(w);
Assert.NotEmpty(w.AllKeys);
Assert.Equal(new[] { "name" }, w.AllKeys);
Assert.Equal("value", w["name"]);
}
[Fact]
public void Getter_Success()
{
string[] keys = { "Accept", "uPgRaDe", "Custom" };
string[] values = { "text/plain, text/html", " HTTP/2.0 , SHTTP/1.3, , RTA/x11 ", "\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\"" };
WebHeaderCollection w = new WebHeaderCollection();
for (int i = 0; i < keys.Length; ++i)
{
string key = keys[i];
string value = values[i];
w[key] = value;
}
for (int i = 0; i < keys.Length; ++i)
{
string key = keys[i];
string expected = values[i].Trim();
Assert.Equal(expected, w[key]);
Assert.Equal(expected, w[key.ToUpperInvariant()]);
Assert.Equal(expected, w[key.ToLowerInvariant()]);
}
}
[Fact]
public void ToString_Empty_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Equal("\r\n", w.ToString());
}
[Theory]
[InlineData(null)]
[InlineData("")]
public void ToString_SingleHeaderWithEmptyValue_Success(string value)
{
WebHeaderCollection w = new WebHeaderCollection();
w["name"] = value;
Assert.Equal("name: \r\n\r\n", w.ToString());
}
[Fact]
public void ToString_NotEmpty_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w["Accept"] = "text/plain";
w["Content-Length"] = "123";
Assert.Equal(
"Accept: text/plain\r\nContent-Length: 123\r\n\r\n",
w.ToString());
}
[Fact]
public void IterateCollection_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w["Accept"] = "text/plain";
w["Content-Length"] = "123";
string result = "";
foreach (var item in w)
{
result += item;
}
Assert.Equal("AcceptContent-Length", result);
}
[Fact]
public void Enumerator_Success()
{
string item1 = "Accept";
string item2 = "Content-Length";
string item3 = "Name";
WebHeaderCollection w = new WebHeaderCollection();
w[item1] = "text/plain";
w[item2] = "123";
w[item3] = "value";
IEnumerable collection = w;
IEnumerator e = collection.GetEnumerator();
for (int i = 0; i < 2; i++)
{
// Not started
Assert.Throws<InvalidOperationException>(() => e.Current);
Assert.True(e.MoveNext());
Assert.Same(item1, e.Current);
Assert.True(e.MoveNext());
Assert.Same(item2, e.Current);
Assert.True(e.MoveNext());
Assert.Same(item3, e.Current);
Assert.False(e.MoveNext());
Assert.False(e.MoveNext());
Assert.False(e.MoveNext());
// Ended
Assert.Throws<InvalidOperationException>(() => e.Current);
e.Reset();
}
}
}
}

View File

@ -0,0 +1,178 @@
// 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.Runtime.Serialization.Formatters.Tests;
using Xunit;
namespace System.Net.WebHeaderCollectionTests
{
public partial class WebHeaderCollectionTest
{
public static IEnumerable<object[]> SerializeDeserialize_Roundtrip_MemberData()
{
for (int i = 0; i < 10; i++)
{
var wc = new WebHeaderCollection();
for (int j = 0; j < i; j++)
{
wc[$"header{j}"] = $"value{j}";
}
yield return new object[] { wc };
}
}
[Theory]
[MemberData(nameof(SerializeDeserialize_Roundtrip_MemberData))]
public void SerializeDeserialize_Roundtrip(WebHeaderCollection c)
{
Assert.Equal(c, BinaryFormatterHelpers.Clone(c));
}
[Fact]
public void HttpRequestHeader_Add_Remove_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add(HttpRequestHeader.Warning, "Warning1");
Assert.Equal(1, w.Count);
Assert.Equal("Warning1", w[HttpRequestHeader.Warning]);
Assert.Equal("Warning", w.AllKeys[0]);
w.Remove(HttpRequestHeader.Warning);
Assert.Equal(0, w.Count);
}
[Fact]
public void HttpRequestHeader_Get_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
string[] values = w.GetValues(0);
Assert.Equal("value1", values[0]);
Assert.Equal("value2", values[1]);
}
[Fact]
public void HttpRequestHeader_ToByteArray_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
byte[] byteArr = w.ToByteArray();
Assert.NotEmpty(byteArr);
}
[Fact]
public void HttpRequestHeader_GetKey_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
Assert.NotEmpty(w.GetKey(0));
}
[Fact]
public void HttpRequestHeader_GetValues_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
Assert.Equal("value1", w.GetValues("header1")[0]);
}
[Fact]
public void HttpRequestHeader_Clear_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
w.Clear();
Assert.Equal(0, w.Count);
}
[Fact]
public void HttpRequestHeader_IsRestricted_Success()
{
Assert.True(WebHeaderCollection.IsRestricted("Accept"));
Assert.False(WebHeaderCollection.IsRestricted("Age"));
Assert.False(WebHeaderCollection.IsRestricted("Accept", true));
}
[Fact]
public void HttpRequestHeader_AddHeader_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add(HttpRequestHeader.ContentLength, "10");
w.Add(HttpRequestHeader.ContentType, "text/html");
Assert.Equal(2,w.Count);
}
[Fact]
public void WebHeaderCollection_Keys_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add(HttpRequestHeader.ContentLength, "10");
w.Add(HttpRequestHeader.ContentType, "text/html");
Assert.Equal(2, w.Keys.Count);
}
[Fact]
public void HttpRequestHeader_AddHeader_Failure()
{
WebHeaderCollection w = new WebHeaderCollection();
char[] arr = new char[ushort.MaxValue + 1];
string maxStr = new string(arr);
Assert.Throws<ArgumentException>(() => w.Add(HttpRequestHeader.ContentLength,maxStr));
Assert.Throws<ArgumentException>(() => w.Add("ContentLength", maxStr));
}
[Fact]
public void HttpRequestHeader_AddMissingColon_Failure()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>(() => w.Add("ContentType#text/html"));
}
[Fact]
public void HttpRequestHeader_Remove_Failure()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>(() => w.Remove(null));
}
[Fact]
public void HttpResponseHeader_Set_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Set(HttpResponseHeader.ProxyAuthenticate, "value123");
Assert.Equal("value123", w[HttpResponseHeader.ProxyAuthenticate]);
}
[Fact]
public void HttpRequestHeader_Set_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Set(HttpRequestHeader.Connection, "keep-alive");
Assert.Equal(1, w.Count);
Assert.Equal("keep-alive", w[HttpRequestHeader.Connection]);
Assert.Equal("Connection", w.AllKeys[0]);
}
[Fact]
public void NameValue_Set_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Set("firstName", "first");
Assert.Equal(1, w.Count);
Assert.NotEmpty(w);
Assert.NotEmpty(w.AllKeys);
Assert.Equal(new[] { "firstName" }, w.AllKeys);
Assert.Equal("first", w["firstName"]);
}
}
}