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