PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/System.Net.Http/System/Net/HttpStatusDescription.cs

#
C# | 105 lines | 96 code | 8 blank | 1 comment | 3 complexity | da1b444af0201700daf636820e3c42de MD5 | raw file
  1using System.Runtime.CompilerServices;
  2
  3namespace System.Net 
  4{
  5    internal static class HttpStatusDescription
  6    {
  7        // from ndp\fx\src\xsp\system\web\workerrequest.cs
  8        private static readonly string[][] httpStatusDescriptions = new string[][] 
  9        {
 10            null,
 11
 12            new string[]
 13            {
 14                /* 100 */ "Continue",
 15                /* 101 */ "Switching Protocols",
 16                /* 102 */ "Processing"
 17            },
 18
 19            new string[]
 20            {
 21                /* 200 */ "OK",
 22                /* 201 */ "Created",
 23                /* 202 */ "Accepted",
 24                /* 203 */ "Non-Authoritative Information",
 25                /* 204 */ "No Content",
 26                /* 205 */ "Reset Content",
 27                /* 206 */ "Partial Content",
 28                /* 207 */ "Multi-Status"
 29            },
 30
 31            new string[]
 32            {
 33                /* 300 */ "Multiple Choices",
 34                /* 301 */ "Moved Permanently",
 35                /* 302 */ "Found",
 36                /* 303 */ "See Other",
 37                /* 304 */ "Not Modified",
 38                /* 305 */ "Use Proxy",
 39                /* 306 */ null,
 40                /* 307 */ "Temporary Redirect"
 41            },
 42
 43            new string[]
 44            {
 45                /* 400 */ "Bad Request",
 46                /* 401 */ "Unauthorized",
 47                /* 402 */ "Payment Required",
 48                /* 403 */ "Forbidden",
 49                /* 404 */ "Not Found",
 50                /* 405 */ "Method Not Allowed",
 51                /* 406 */ "Not Acceptable",
 52                /* 407 */ "Proxy Authentication Required",
 53                /* 408 */ "Request Timeout",
 54                /* 409 */ "Conflict",
 55                /* 410 */ "Gone",
 56                /* 411 */ "Length Required",
 57                /* 412 */ "Precondition Failed",
 58                /* 413 */ "Request Entity Too Large",
 59                /* 414 */ "Request-Uri Too Long",
 60                /* 415 */ "Unsupported Media Type",
 61                /* 416 */ "Requested Range Not Satisfiable",
 62                /* 417 */ "Expectation Failed",
 63                /* 418 */ null,
 64                /* 419 */ null,
 65                /* 420 */ null,
 66                /* 421 */ null,
 67                /* 422 */ "Unprocessable Entity",
 68                /* 423 */ "Locked",
 69                /* 424 */ "Failed Dependency",
 70                /* 425 */ null
 71            },
 72
 73            new string[]
 74            {
 75                /* 500 */ "Internal Server Error",
 76                /* 501 */ "Not Implemented",
 77                /* 502 */ "Bad Gateway",
 78                /* 503 */ "Service Unavailable",
 79                /* 504 */ "Gateway Timeout",
 80                /* 505 */ "Http Version Not Supported",
 81                /* 506 */ null,
 82                /* 507 */ "Insufficient Storage"
 83            }
 84        };
 85
 86        internal static string Get(HttpStatusCode code)
 87        {
 88            return Get((int)code);
 89        }
 90
 91        internal static string Get(int code)
 92        {
 93            if (code >= 100 && code < 600)
 94            {
 95                int i = code / 100;
 96                int j = code % 100;
 97                if (j < httpStatusDescriptions[i].Length)
 98                {
 99                    return httpStatusDescriptions[i][j];
100                }
101            }
102            return null;
103        }
104    }
105}