Move the reason phrase lookup to WebUtilities.
This commit is contained in:
parent
cd238d4545
commit
6444f3e15d
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics
|
||||
{
|
||||
// TODO: Move this into Abstractions
|
||||
public static class ReasonPhraseHelper
|
||||
{
|
||||
private static IDictionary<int, string> Phrases = new Dictionary<int, string>()
|
||||
{
|
||||
{ 200, "OK" },
|
||||
{ 201, "Created" },
|
||||
{ 202, "Accepted" },
|
||||
{ 203, "Non-Authoritative Information" },
|
||||
{ 204, "No Content" },
|
||||
{ 205, "Reset Content" },
|
||||
{ 206, "Partial Content" },
|
||||
|
||||
{ 300, "Multiple Choices" },
|
||||
{ 301, "Moved Permanently" },
|
||||
{ 302, "Found" },
|
||||
{ 303, "See Other" },
|
||||
{ 304, "Not Modified" },
|
||||
{ 305, "Use Proxy" },
|
||||
{ 306, "Switch Proxy" },
|
||||
{ 307, "Temporary Redirect" },
|
||||
|
||||
{ 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, "I'm a teapot" },
|
||||
{ 419, "Authentication Timeout" },
|
||||
|
||||
{ 500, "Internal Server Error" },
|
||||
{ 501, "Not Implemented" },
|
||||
{ 502, "Bad Gateway" },
|
||||
{ 503, "Service Unavailable" },
|
||||
{ 504, "Gateway Timeout" },
|
||||
{ 505, "HTTP Version Not Supported" },
|
||||
{ 506, "Variant Also Negotiates" },
|
||||
};
|
||||
|
||||
public static string GetReasonPhrase(int statusCode)
|
||||
{
|
||||
string phrase;
|
||||
return Phrases.TryGetValue(statusCode, out phrase) ? phrase : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics
|
||||
{
|
||||
|
|
@ -18,7 +19,7 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
// Note the 500 spaces are to work around an IE 'feature'
|
||||
var statusCode = context.HttpContext.Response.StatusCode;
|
||||
var body = string.Format(CultureInfo.InvariantCulture, "Status Code: {0}; {1}",
|
||||
statusCode, ReasonPhraseHelper.GetReasonPhrase(statusCode)) + new string(' ', 500);
|
||||
statusCode, ReasonPhrases.GetReasonPhrase(statusCode)) + new string(' ', 500);
|
||||
return context.HttpContext.Response.SendAsync(body, "text/plain");
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"description": "ASP.NET 5 Middleware for error handling, error pages, and diagnostics information.",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.RequestContainer": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue