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