Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5fdac17

Browse files
committed
Merge pull request #2358 from pgavlin/Networking
Initial commit of System.Net.WebHeaderCollection
2 parents fc96be9 + 8c9d941 commit 5fdac17

15 files changed

+3212
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace System.Net
5+
{
6+
internal static class HttpKnownHeaderNames
7+
{
8+
public const string Accept = "Accept";
9+
public const string AcceptCharset = "Accept-Charset";
10+
public const string AcceptEncoding = "Accept-Encoding";
11+
public const string AcceptLanguage = "Accept-Language";
12+
public const string AcceptRanges = "Accept-Ranges";
13+
public const string Age = "Age";
14+
public const string Allow = "Allow";
15+
public const string Authorization = "Authorization";
16+
public const string CacheControl = "Cache-Control";
17+
public const string Connection = "Connection";
18+
public const string ContentDisposition = "Content-Disposition";
19+
public const string ContentEncoding = "Content-Encoding";
20+
public const string ContentLanguage = "Content-Language";
21+
public const string ContentLength = "Content-Length";
22+
public const string ContentLocation = "Content-Location";
23+
public const string ContentMD5 = "Content-MD5";
24+
public const string ContentRange = "Content-Range";
25+
public const string ContentType = "Content-Type";
26+
public const string Cookie = "Cookie";
27+
public const string Cookie2 = "Cookie2";
28+
public const string Date = "Date";
29+
public const string ETag = "ETag";
30+
public const string Expect = "Expect";
31+
public const string Expires = "Expires";
32+
public const string From = "From";
33+
public const string Host = "Host";
34+
public const string IfMatch = "If-Match";
35+
public const string IfModifiedSince = "If-Modified-Since";
36+
public const string IfNoneMatch = "If-None-Match";
37+
public const string IfRange = "If-Range";
38+
public const string IfUnmodifiedSince = "If-Unmodified-Since";
39+
public const string KeepAlive = "Keep-Alive";
40+
public const string LastModified = "Last-Modified";
41+
public const string Location = "Location";
42+
public const string MaxForwards = "Max-Forwards";
43+
public const string Origin = "Origin";
44+
public const string P3P = "P3P";
45+
public const string Pragma = "Pragma";
46+
public const string ProxyAuthenticate = "Proxy-Authenticate";
47+
public const string ProxyAuthorization = "Proxy-Authorization";
48+
public const string ProxyConnection = "Proxy-Connection";
49+
public const string Range = "Range";
50+
public const string Referer = "Referer";
51+
public const string RetryAfter = "Retry-After";
52+
public const string SecWebSocketAccept = "Sec-WebSocket-Accept";
53+
public const string SecWebSocketExtensions = "Sec-WebSocket-Extensions";
54+
public const string SecWebSocketKey = "Sec-WebSocket-Key";
55+
public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol";
56+
public const string SecWebSocketVersion = "Sec-WebSocket-Version";
57+
public const string Server = "Server";
58+
public const string SetCookie = "Set-Cookie";
59+
public const string SetCookie2 = "Set-Cookie2";
60+
public const string TE = "TE";
61+
public const string Trailer = "Trailer";
62+
public const string TransferEncoding = "Transfer-Encoding";
63+
public const string Upgrade = "Upgrade";
64+
public const string UserAgent = "User-Agent";
65+
public const string Vary = "Vary";
66+
public const string Via = "Via";
67+
public const string WWWAuthenticate = "WWW-Authenticate";
68+
public const string Warning = "Warning";
69+
public const string XAspNetVersion = "X-AspNet-Version";
70+
public const string XPoweredBy = "X-Powered-By";
71+
}
72+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.22823.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.WebHeaderCollection", "src\System.Net.WebHeaderCollection.csproj", "{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.WebHeaderCollection.Tests", "tests\System.Net.WebHeaderCollection.Tests.csproj", "{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
FreeBSD_Debug|Any CPU = FreeBSD_Debug|Any CPU
13+
FreeBSD_Release|Any CPU = FreeBSD_Release|Any CPU
14+
Linux_Debug|Any CPU = Linux_Debug|Any CPU
15+
Linux_Release|Any CPU = Linux_Release|Any CPU
16+
OSX_Debug|Any CPU = OSX_Debug|Any CPU
17+
OSX_Release|Any CPU = OSX_Release|Any CPU
18+
Windows_Debug|Any CPU = Windows_Debug|Any CPU
19+
Windows_Release|Any CPU = Windows_Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.FreeBSD_Debug|Any CPU.ActiveCfg = FreeBSD_Debug|Any CPU
23+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.FreeBSD_Debug|Any CPU.Build.0 = FreeBSD_Debug|Any CPU
24+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.FreeBSD_Release|Any CPU.ActiveCfg = FreeBSD_Release|Any CPU
25+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.FreeBSD_Release|Any CPU.Build.0 = FreeBSD_Release|Any CPU
26+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Linux_Debug|Any CPU.ActiveCfg = Linux_Debug|Any CPU
27+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Linux_Debug|Any CPU.Build.0 = Linux_Debug|Any CPU
28+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Linux_Release|Any CPU.ActiveCfg = Linux_Release|Any CPU
29+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Linux_Release|Any CPU.Build.0 = Linux_Release|Any CPU
30+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.OSX_Debug|Any CPU.ActiveCfg = OSX_Debug|Any CPU
31+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.OSX_Debug|Any CPU.Build.0 = OSX_Debug|Any CPU
32+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.OSX_Release|Any CPU.ActiveCfg = OSX_Release|Any CPU
33+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.OSX_Release|Any CPU.Build.0 = OSX_Release|Any CPU
34+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
35+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
36+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
37+
{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
38+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.FreeBSD_Debug|Any CPU.ActiveCfg = FreeBSD_Debug|Any CPU
39+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.FreeBSD_Debug|Any CPU.Build.0 = FreeBSD_Debug|Any CPU
40+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.FreeBSD_Release|Any CPU.ActiveCfg = FreeBSD_Release|Any CPU
41+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.FreeBSD_Release|Any CPU.Build.0 = FreeBSD_Release|Any CPU
42+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Linux_Debug|Any CPU.ActiveCfg = Linux_Debug|Any CPU
43+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Linux_Debug|Any CPU.Build.0 = Linux_Debug|Any CPU
44+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Linux_Release|Any CPU.ActiveCfg = Linux_Release|Any CPU
45+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Linux_Release|Any CPU.Build.0 = Linux_Release|Any CPU
46+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.OSX_Debug|Any CPU.ActiveCfg = OSX_Debug|Any CPU
47+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.OSX_Debug|Any CPU.Build.0 = OSX_Debug|Any CPU
48+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.OSX_Release|Any CPU.ActiveCfg = OSX_Release|Any CPU
49+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.OSX_Release|Any CPU.Build.0 = OSX_Release|Any CPU
50+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
51+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
52+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
53+
{F8C21EE8-B271-4014-B9D9-B2C31520AF3F}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
54+
EndGlobalSection
55+
GlobalSection(SolutionProperties) = preSolution
56+
HideSolutionNode = FALSE
57+
EndGlobalSection
58+
EndGlobal
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
<data name="net_headers_req" xml:space="preserve">
121+
<value>This collection holds response headers and cannot contain the specified request header.</value>
122+
</data>
123+
<data name="net_headers_rsp" xml:space="preserve">
124+
<value>This collection holds request headers and cannot contain the specified response header.</value>
125+
</data>
126+
<data name="net_headers_toolong" xml:space="preserve">
127+
<value>Header values cannot be longer than {0} characters.</value>
128+
</data>
129+
<data name="net_WebHeaderInvalidControlChars" xml:space="preserve">
130+
<value>Specified value has invalid Control characters.</value>
131+
</data>
132+
<data name="net_WebHeaderInvalidCRLFChars" xml:space="preserve">
133+
<value>Specified value has invalid CRLF characters.</value>
134+
</data>
135+
<data name="net_WebHeaderInvalidHeaderChars" xml:space="preserve">
136+
<value>Specified value has invalid HTTP Header characters.</value>
137+
</data>
138+
<data name="net_WebHeaderInvalidNonAsciiChars" xml:space="preserve">
139+
<value>Specified value has invalid non-ASCII characters.</value>
140+
</data>
141+
<data name="net_WebHeaderMissingColon" xml:space="preserve">
142+
<value>Specified value does not have a ':' separator.</value>
143+
</data>
144+
<data name="net_headerrestrict" xml:space="preserve">
145+
<value>The '{0}' header must be modified using the appropriate property or method.</value>
146+
</data>
147+
<data name="net_emptystringcall" xml:space="preserve">
148+
<value>The parameter '{0}' cannot be an empty string.</value>
149+
</data>
150+
</root>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Windows_Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5EE76DCC-9FD5-47FD-AB45-BD0F0857740F}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
</PropertyGroup>
10+
11+
<!-- Help VS understand available configurations -->
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FreeBSD_Debug|AnyCPU' " />
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FreeBSD_Release|AnyCPU' " />
14+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Debug|AnyCPU' " />
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Release|AnyCPU' " />
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Debug|AnyCPU' " />
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Release|AnyCPU' " />
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Debug|AnyCPU' " />
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Release|AnyCPU' " />
20+
21+
<ItemGroup>
22+
<Compile Include="System\Net\WebHeaderCollection.cs" />
23+
<Compile Include="System\Net\HttpResponseHeader.cs" />
24+
<Compile Include="System\Net\HttpRequestHeader.cs" />
25+
<Compile Include="System\Net\HeaderInfo.cs" />
26+
<Compile Include="System\Net\HeaderInfoTable.cs" />
27+
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
28+
<Link>Common\System\Net\HttpKnownHeaderNames.cs</Link>
29+
</Compile>
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<None Include="project.json" />
34+
</ItemGroup>
35+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
36+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace System.Net
5+
{
6+
internal delegate string[] HeaderParser(string value);
7+
8+
internal class HeaderInfo
9+
{
10+
internal readonly bool IsRequestRestricted;
11+
internal readonly bool IsResponseRestricted;
12+
internal readonly HeaderParser Parser;
13+
14+
// Note that the HeaderName field is not always valid, and should not
15+
// be used after initialization. In particular, the HeaderInfo returned
16+
// for an unknown header will not have the correct header name.
17+
18+
internal readonly string HeaderName;
19+
internal readonly bool AllowMultiValues;
20+
21+
internal HeaderInfo(string name, bool requestRestricted, bool responseRestricted, bool multi, HeaderParser p)
22+
{
23+
HeaderName = name;
24+
IsRequestRestricted = requestRestricted;
25+
IsResponseRestricted = responseRestricted;
26+
Parser = p;
27+
AllowMultiValues = multi;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)