status.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_HTTP_STATUS_HPP
  10. #define BOOST_BEAST_HTTP_STATUS_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. #include <boost/beast/core/string.hpp>
  13. #include <iosfwd>
  14. namespace boost {
  15. namespace beast {
  16. namespace http {
  17. enum class status : unsigned
  18. {
  19. /** An unknown status-code.
  20. This value indicates that the value for the status code
  21. is not in the list of commonly recognized status codes.
  22. Callers interested in the exactly value should use the
  23. interface which provides the raw integer.
  24. */
  25. unknown = 0,
  26. continue_ = 100,
  27. switching_protocols = 101,
  28. processing = 102,
  29. ok = 200,
  30. created = 201,
  31. accepted = 202,
  32. non_authoritative_information = 203,
  33. no_content = 204,
  34. reset_content = 205,
  35. partial_content = 206,
  36. multi_status = 207,
  37. already_reported = 208,
  38. im_used = 226,
  39. multiple_choices = 300,
  40. moved_permanently = 301,
  41. found = 302,
  42. see_other = 303,
  43. not_modified = 304,
  44. use_proxy = 305,
  45. temporary_redirect = 307,
  46. permanent_redirect = 308,
  47. bad_request = 400,
  48. unauthorized = 401,
  49. payment_required = 402,
  50. forbidden = 403,
  51. not_found = 404,
  52. method_not_allowed = 405,
  53. not_acceptable = 406,
  54. proxy_authentication_required = 407,
  55. request_timeout = 408,
  56. conflict = 409,
  57. gone = 410,
  58. length_required = 411,
  59. precondition_failed = 412,
  60. payload_too_large = 413,
  61. uri_too_long = 414,
  62. unsupported_media_type = 415,
  63. range_not_satisfiable = 416,
  64. expectation_failed = 417,
  65. misdirected_request = 421,
  66. unprocessable_entity = 422,
  67. locked = 423,
  68. failed_dependency = 424,
  69. upgrade_required = 426,
  70. precondition_required = 428,
  71. too_many_requests = 429,
  72. request_header_fields_too_large = 431,
  73. connection_closed_without_response = 444,
  74. unavailable_for_legal_reasons = 451,
  75. client_closed_request = 499,
  76. internal_server_error = 500,
  77. not_implemented = 501,
  78. bad_gateway = 502,
  79. service_unavailable = 503,
  80. gateway_timeout = 504,
  81. http_version_not_supported = 505,
  82. variant_also_negotiates = 506,
  83. insufficient_storage = 507,
  84. loop_detected = 508,
  85. not_extended = 510,
  86. network_authentication_required = 511,
  87. network_connect_timeout_error = 599
  88. };
  89. /** Represents the class of a status-code.
  90. */
  91. enum class status_class : unsigned
  92. {
  93. /// Unknown status-class
  94. unknown = 0,
  95. /// The request was received, continuing processing.
  96. informational = 1,
  97. /// The request was successfully received, understood, and accepted.
  98. successful = 2,
  99. /// Further action needs to be taken in order to complete the request.
  100. redirection = 3,
  101. /// The request contains bad syntax or cannot be fulfilled.
  102. client_error = 4,
  103. /// The server failed to fulfill an apparently valid request.
  104. server_error = 5,
  105. };
  106. /** Converts the integer to a known status-code.
  107. If the integer does not match a known status code,
  108. @ref status::unknown is returned.
  109. */
  110. status
  111. int_to_status(unsigned v);
  112. /** Convert an integer to a status_class.
  113. @param v The integer representing a status code.
  114. @return The status class. If the integer does not match
  115. a known status class, @ref status_class::unknown is returned.
  116. */
  117. status_class
  118. to_status_class(unsigned v);
  119. /** Convert a status_code to a status_class.
  120. @param v The status code to convert.
  121. @return The status class.
  122. */
  123. status_class
  124. to_status_class(status v);
  125. /** Returns the obsolete reason-phrase text for a status code.
  126. @param v The status code to use.
  127. */
  128. string_view
  129. obsolete_reason(status v);
  130. /// Outputs the standard reason phrase of a status code to a stream.
  131. std::ostream&
  132. operator<<(std::ostream&, status);
  133. } // http
  134. } // beast
  135. } // boost
  136. #include <boost/beast/http/impl/status.ipp>
  137. #endif