httpcodes.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #include "httpcodes.h"
  2. TStringBuf HttpCodeStrEx(int code) noexcept {
  3. switch (code) {
  4. case HTTP_CONTINUE:
  5. return TStringBuf("100 Continue");
  6. case HTTP_SWITCHING_PROTOCOLS:
  7. return TStringBuf("101 Switching protocols");
  8. case HTTP_PROCESSING:
  9. return TStringBuf("102 Processing");
  10. case HTTP_EARLY_HINTS:
  11. return TStringBuf ("103 Early Hints");
  12. case HTTP_OK:
  13. return TStringBuf("200 Ok");
  14. case HTTP_CREATED:
  15. return TStringBuf("201 Created");
  16. case HTTP_ACCEPTED:
  17. return TStringBuf("202 Accepted");
  18. case HTTP_NON_AUTHORITATIVE_INFORMATION:
  19. return TStringBuf("203 None authoritative information");
  20. case HTTP_NO_CONTENT:
  21. return TStringBuf("204 No content");
  22. case HTTP_RESET_CONTENT:
  23. return TStringBuf("205 Reset content");
  24. case HTTP_PARTIAL_CONTENT:
  25. return TStringBuf("206 Partial content");
  26. case HTTP_MULTI_STATUS:
  27. return TStringBuf("207 Multi status");
  28. case HTTP_ALREADY_REPORTED:
  29. return TStringBuf("208 Already reported");
  30. case HTTP_IM_USED:
  31. return TStringBuf("226 IM used");
  32. case HTTP_MULTIPLE_CHOICES:
  33. return TStringBuf("300 Multiple choices");
  34. case HTTP_MOVED_PERMANENTLY:
  35. return TStringBuf("301 Moved permanently");
  36. case HTTP_FOUND:
  37. return TStringBuf("302 Moved temporarily");
  38. case HTTP_SEE_OTHER:
  39. return TStringBuf("303 See other");
  40. case HTTP_NOT_MODIFIED:
  41. return TStringBuf("304 Not modified");
  42. case HTTP_USE_PROXY:
  43. return TStringBuf("305 Use proxy");
  44. case HTTP_TEMPORARY_REDIRECT:
  45. return TStringBuf("307 Temporarily redirect");
  46. case HTTP_PERMANENT_REDIRECT:
  47. return TStringBuf("308 Permanent redirect");
  48. case HTTP_BAD_REQUEST:
  49. return TStringBuf("400 Bad request");
  50. case HTTP_UNAUTHORIZED:
  51. return TStringBuf("401 Unauthorized");
  52. case HTTP_PAYMENT_REQUIRED:
  53. return TStringBuf("402 Payment required");
  54. case HTTP_FORBIDDEN:
  55. return TStringBuf("403 Forbidden");
  56. case HTTP_NOT_FOUND:
  57. return TStringBuf("404 Not found");
  58. case HTTP_METHOD_NOT_ALLOWED:
  59. return TStringBuf("405 Method not allowed");
  60. case HTTP_NOT_ACCEPTABLE:
  61. return TStringBuf("406 Not acceptable");
  62. case HTTP_PROXY_AUTHENTICATION_REQUIRED:
  63. return TStringBuf("407 Proxy Authentication required");
  64. case HTTP_REQUEST_TIME_OUT:
  65. return TStringBuf("408 Request time out");
  66. case HTTP_CONFLICT:
  67. return TStringBuf("409 Conflict");
  68. case HTTP_GONE:
  69. return TStringBuf("410 Gone");
  70. case HTTP_LENGTH_REQUIRED:
  71. return TStringBuf("411 Length required");
  72. case HTTP_PRECONDITION_FAILED:
  73. return TStringBuf("412 Precondition failed");
  74. case HTTP_REQUEST_ENTITY_TOO_LARGE:
  75. return TStringBuf("413 Request entity too large");
  76. case HTTP_REQUEST_URI_TOO_LARGE:
  77. return TStringBuf("414 Request uri too large");
  78. case HTTP_UNSUPPORTED_MEDIA_TYPE:
  79. return TStringBuf("415 Unsupported media type");
  80. case HTTP_REQUESTED_RANGE_NOT_SATISFIABLE:
  81. return TStringBuf("416 Requested Range Not Satisfiable");
  82. case HTTP_EXPECTATION_FAILED:
  83. return TStringBuf("417 Expectation Failed");
  84. case HTTP_I_AM_A_TEAPOT:
  85. return TStringBuf("418 I Am A Teapot");
  86. case HTTP_AUTHENTICATION_TIMEOUT:
  87. return TStringBuf("419 Authentication Timeout");
  88. case HTTP_MISDIRECTED_REQUEST:
  89. return TStringBuf("421 Misdirected Request");
  90. case HTTP_UNPROCESSABLE_ENTITY:
  91. return TStringBuf("422 Unprocessable Entity");
  92. case HTTP_LOCKED:
  93. return TStringBuf("423 Locked");
  94. case HTTP_FAILED_DEPENDENCY:
  95. return TStringBuf("424 Failed Dependency");
  96. case HTTP_UNORDERED_COLLECTION:
  97. return TStringBuf("425 Unordered Collection");
  98. case HTTP_UPGRADE_REQUIRED:
  99. return TStringBuf("426 Upgrade Required");
  100. case HTTP_PRECONDITION_REQUIRED:
  101. return TStringBuf("428 Precondition Required");
  102. case HTTP_TOO_MANY_REQUESTS:
  103. return TStringBuf("429 Too Many Requests");
  104. case HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE:
  105. return TStringBuf("431 Request Header Fields Too Large");
  106. case HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
  107. return TStringBuf("451 Unavailable For Legal Reason");
  108. case HTTP_INTERNAL_SERVER_ERROR:
  109. return TStringBuf("500 Internal server error");
  110. case HTTP_NOT_IMPLEMENTED:
  111. return TStringBuf("501 Not implemented");
  112. case HTTP_BAD_GATEWAY:
  113. return TStringBuf("502 Bad gateway");
  114. case HTTP_SERVICE_UNAVAILABLE:
  115. return TStringBuf("503 Service unavailable");
  116. case HTTP_GATEWAY_TIME_OUT:
  117. return TStringBuf("504 Gateway time out");
  118. case HTTP_HTTP_VERSION_NOT_SUPPORTED:
  119. return TStringBuf("505 HTTP version not supported");
  120. case HTTP_VARIANT_ALSO_NEGOTIATES:
  121. return TStringBuf("506 Variant also negotiates");
  122. case HTTP_INSUFFICIENT_STORAGE:
  123. return TStringBuf("507 Insufficient storage");
  124. case HTTP_LOOP_DETECTED:
  125. return TStringBuf("508 Loop Detected");
  126. case HTTP_BANDWIDTH_LIMIT_EXCEEDED:
  127. return TStringBuf("509 Bandwidth Limit Exceeded");
  128. case HTTP_NOT_EXTENDED:
  129. return TStringBuf("510 Not Extended");
  130. case HTTP_NETWORK_AUTHENTICATION_REQUIRED:
  131. return TStringBuf("511 Network Authentication Required");
  132. case HTTP_UNASSIGNED_512:
  133. return TStringBuf("512 Unassigned");
  134. default:
  135. return TStringBuf("000 Unknown HTTP code");
  136. }
  137. }