Merge pull request dotnet/corefx#3199 from justinvp/winhttphandler_parseresponseheaders

Reduce allocations when parsing response headers in WinHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/35f7ef05a8022358ec435152e7099d8263a4422a
This commit is contained in:
David Shulman committed 2016-02-18 15:52:45 -08:00
commit 52476494de
19 files changed
+1177 -247

No files matched your search

@@ -1,109 +0,0 @@
// 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.Runtime.CompilerServices;
namespace System.Net
{
internal static class HttpStatusDescription
{
private static readonly string[][] s_httpStatusDescriptions = new string[][]
{
null,
new string[]
{
/* 100 */ "Continue",
/* 101 */ "Switching Protocols",
/* 102 */ "Processing"
},
new string[]
{
/* 200 */ "OK",
/* 201 */ "Created",
/* 202 */ "Accepted",
/* 203 */ "Non-Authoritative Information",
/* 204 */ "No Content",
/* 205 */ "Reset Content",
/* 206 */ "Partial Content",
/* 207 */ "Multi-Status"
},
new string[]
{
/* 300 */ "Multiple Choices",
/* 301 */ "Moved Permanently",
/* 302 */ "Found",
/* 303 */ "See Other",
/* 304 */ "Not Modified",
/* 305 */ "Use Proxy",
/* 306 */ null,
/* 307 */ "Temporary Redirect"
},
new string[]
{
/* 400 */ "Bad Request",
/* 401 */ "Unauthorized",
/* 402 */ "Payment Required",
/* 403 */ "Forbidden",
/* 404 */ "Not Found",
/* 405 */ "Method Not Allowed",
/* 406 */ "Not Acceptable",
/* 407 */ "Proxy Authentication Required",
/* 408 */ "Request Timeout",
/* 409 */ "Conflict",
/* 410 */ "Gone",
/* 411 */ "Length Required",
/* 412 */ "Precondition Failed",
/* 413 */ "Request Entity Too Large",
/* 414 */ "Request-Uri Too Long",
/* 415 */ "Unsupported Media Type",
/* 416 */ "Requested Range Not Satisfiable",
/* 417 */ "Expectation Failed",
/* 418 */ null,
/* 419 */ null,
/* 420 */ null,
/* 421 */ null,
/* 422 */ "Unprocessable Entity",
/* 423 */ "Locked",
/* 424 */ "Failed Dependency",
/* 425 */ null,
/* 426 */ "Upgrade Required", // RFC 2817
},
new string[]
{
/* 500 */ "Internal Server Error",
/* 501 */ "Not Implemented",
/* 502 */ "Bad Gateway",
/* 503 */ "Service Unavailable",
/* 504 */ "Gateway Timeout",
/* 505 */ "Http Version Not Supported",
/* 506 */ null,
/* 507 */ "Insufficient Storage"
}
};
internal static string Get(HttpStatusCode code)
{
return Get((int)code);
}
internal static string Get(int code)
{
if (code >= 100 && code < 600)
{
int i = code / 100;
int j = code % 100;
if (j < s_httpStatusDescriptions[i].Length)
{
return s_httpStatusDescriptions[i][j];
}
}
return null;
}
}
}
@@ -105,7 +105,6 @@
<Compile Include="System\Net\Http\Headers\WarningHeaderValue.cs" />
<!-- TODO #5715: Must be moved to the Common/System/Net folder -->
<Compile Include="Internal\ICloneable.cs" />
<Compile Include="Internal\HttpStatusDescription.cs" />
<Compile Include="Internal\MailAddress.cs" />
<Compile Include="Internal\Mail\DomainLiteralReader.cs" />
<Compile Include="Internal\Mail\DotAtomReader.cs" />
@@ -114,9 +113,6 @@
<Compile Include="Internal\Mail\QuotedPairReader.cs" />
<Compile Include="Internal\Mail\QuotedStringFormatReader.cs" />
<Compile Include="Internal\Mail\WhitespaceReader.cs" />
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>Common\System\Net\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\LoggingHash.cs">
<Link>Common\System\Net\Logging\LoggingHash.cs</Link>
</Compile>
@@ -218,6 +214,12 @@
<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\HttpStatusDescription.cs">
<Link>Common\System\Net\HttpStatusDescription.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpVersion.cs">
<Link>Common\System\Net\HttpVersion.cs</Link>
</Compile>
@@ -308,6 +310,12 @@
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerLoggingStrings.cs">
<Link>Common\System\Net\Http\HttpHandlerLoggingStrings.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>Common\System\Net\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpStatusDescription.cs">
<Link>Common\System\Net\HttpStatusDescription.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpVersion.cs">
<Link>Common\System\Net\HttpVersion.cs</Link>
</Compile>
@@ -32,12 +32,27 @@
<Compile Include="$(CommonPath)\System\StringExtensions.cs">
<Link>ProductionCode\Common\System\StringExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>ProductionCode\Common\System\Net\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpStatusDescription.cs">
<Link>ProductionCode\Common\System\Net\HttpStatusDescription.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpVersion.cs">
<Link>ProductionCode\Common\System\Net\HttpVersion.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\LoggingHash.cs">
<Link>ProductionCode\Common\System\Net\Logging\LoggingHash.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\HttpEventSource.cs">
<Link>ProductionCode\Common\System\Net\Logging\HttpEventSource.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.cs">
<Link>ProductionCode\Common\System\Net\Logging\NetEventSource.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\ShouldNotBeInvokedException.cs">
<Link>Common\System\ShouldNotBeInvokedException.cs</Link>
</Compile>
<Compile Include="..\..\src\Internal\HttpStatusDescription.cs">
<Link>ProductionCode\Internal\HttpStatusDescription.cs</Link>
</Compile>
<Compile Include="..\..\src\Internal\ICloneable.cs">
<Link>ProductionCode\Internal\ICloneable.cs</Link>
</Compile>
@@ -323,22 +338,6 @@
<Compile Include="HttpContentTest.cs" />
<Compile Include="HttpRuleParserTest.cs" />
<Compile Include="MockContent.cs" />
<Compile Include="$(CommonPath)\System\Net\HttpKnownHeaderNames.cs">
<Link>ProductionCode\HttpKnownHeaderNames.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\HttpVersion.cs">
<Link>Common\System\Net\HttpVersion.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\LoggingHash.cs">
<Link>Common\System\Net\Logging\LoggingHash.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\HttpEventSource.cs">
<Link>Common\System\Net\Logging\HttpEventSource.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.cs">
<Link>Common\System\Net\Logging\NetEventSource.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="project.json" />