Skip to content

Commit 6eb8e03

Browse files
committed
Lower case enum for HTTP status code for consistency.
1 parent ce3bccf commit 6eb8e03

File tree

2 files changed

+89
-89
lines changed

2 files changed

+89
-89
lines changed

http/src/network/http/v2/status.hpp

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,58 @@ namespace network {
2424
namespace status {
2525
enum class code {
2626
// informational
27-
CONTINUE = 100,
28-
SWITCH_PROTOCOLS = 101,
27+
continue_ = 100,
28+
switch_protocols = 101,
2929

3030
// successful
31-
OK = 200,
32-
CREATED = 201,
33-
ACCEPTED = 202,
34-
NON_AUTH_INFO = 203,
35-
NO_CONTENT = 204,
36-
RESET_CONTENT = 205,
37-
PARTIAL_CONTENT = 206,
31+
ok = 200,
32+
created = 201,
33+
accepted = 202,
34+
non_auth_info = 203,
35+
no_content = 204,
36+
reset_content = 205,
37+
partial_content = 206,
3838

3939
// redirection
40-
MULTIPLE_CHOICES = 300,
41-
MOVED_PERMANENTLY = 301,
42-
FOUND = 302,
43-
SEE_OTHER = 303,
44-
NOT_MODIFIED = 304,
45-
USE_PROXY = 305,
46-
TEMPORARY_REDIRECT = 307,
40+
multiple_choices = 300,
41+
moved_permanently = 301,
42+
found = 302,
43+
see_other = 303,
44+
not_modified = 304,
45+
use_proxy = 305,
46+
temporary_redirect = 307,
4747

4848
// client error
49-
BAD_REQUEST = 400,
50-
UNAUTHORIZED = 401,
51-
PAYMENT_REQUIRED = 402,
52-
FORBIDDEN = 403,
53-
NOT_FOUND = 404,
54-
METHOD_NOT_ALLOWED = 405,
55-
NOT_ACCEPTABLE = 406,
56-
PROXY_AUTH_REQUIRED = 407,
57-
REQUEST_TIMEOUT = 408,
58-
CONFLICT = 409,
59-
GONE = 410,
60-
LENGTH_REQUIRED = 411,
61-
PRECONDITION_FAILED = 412,
62-
REQUEST_ENTITY_TOO_LARGE = 413,
63-
REQUEST_URI_TOO_LONG = 414,
64-
UNSUPPORTED_MEDIA_TYPE = 415,
65-
REQUEST_RANGE_NOT_SATISFIABLE = 416,
66-
EXPECTATION_FAILED = 417,
67-
PRECONDITION_REQUIRED = 428,
68-
TOO_MANY_REQUESTS = 429,
69-
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
49+
bad_request = 400,
50+
unauthorized = 401,
51+
payment_required = 402,
52+
forbidden = 403,
53+
not_found = 404,
54+
method_not_allowed = 405,
55+
not_acceptable = 406,
56+
proxy_auth_required = 407,
57+
request_timeout = 408,
58+
conflict = 409,
59+
gone = 410,
60+
length_required = 411,
61+
precondition_failed = 412,
62+
request_entity_too_large = 413,
63+
request_uri_too_long = 414,
64+
unsupported_media_type = 415,
65+
request_range_not_satisfiable = 416,
66+
expectation_failed = 417,
67+
precondition_required = 428,
68+
too_many_requests = 429,
69+
request_header_fields_too_large = 431,
7070

7171
// server error
72-
INTERNAL_ERROR = 500,
73-
NOT_IMPLEMENTED = 501,
74-
BAD_GATEWAY = 502,
75-
SERVICE_UNAVAILABLE = 503,
76-
GATEWAY_TIMEOUT = 504,
77-
HTTP_VERSION_NOT_SUPPORTED = 505,
78-
NETWORK_AUTHENTICATION_REQUIRED = 511,
72+
internal_error = 500,
73+
not_implemented = 501,
74+
bad_gateway = 502,
75+
service_unavailable = 503,
76+
gateway_timeout = 504,
77+
http_version_not_supported = 505,
78+
network_authentication_required = 511,
7979
};
8080
} // namespace status
8181
} // namespace v2
@@ -101,50 +101,50 @@ namespace network {
101101
inline
102102
std::string message(code status_code) {
103103
static std::unordered_map<code, std::string> status_messages{
104-
{code::CONTINUE, "Continue"},
105-
{code::SWITCH_PROTOCOLS, "Switching Protocols"},
106-
{code::OK, "OK"},
107-
{code::CREATED, "Created"},
108-
{code::ACCEPTED, "Accepted"},
109-
{code::NON_AUTH_INFO, "Non-Authoritative Information"},
110-
{code::NO_CONTENT, "No Content"},
111-
{code::RESET_CONTENT, "Reset Content"},
112-
{code::PARTIAL_CONTENT, "Partial Content"},
113-
{code::MULTIPLE_CHOICES, "Multiple Choices"},
114-
{code::MOVED_PERMANENTLY, "Moved Permanently"},
115-
{code::FOUND, "Found"},
116-
{code::SEE_OTHER, "See Other"},
117-
{code::NOT_MODIFIED, "Not Modified"},
118-
{code::USE_PROXY, "Use Proxy"},
119-
{code::TEMPORARY_REDIRECT, "Temporary Redirect"},
120-
{code::BAD_REQUEST, "Bad Request"},
121-
{code::UNAUTHORIZED, "Unauthorized"},
122-
{code::PAYMENT_REQUIRED, "Payment Required"},
123-
{code::FORBIDDEN, "Forbidden"},
124-
{code::NOT_FOUND, "Not Found"},
125-
{code::METHOD_NOT_ALLOWED, "Method Not Allowed"},
126-
{code::NOT_ACCEPTABLE, "Not Acceptable"},
127-
{code::PROXY_AUTH_REQUIRED, "Proxy Authentication Required"},
128-
{code::REQUEST_TIMEOUT, "Request Timeout"},
129-
{code::CONFLICT, "Conflict"},
130-
{code::GONE, "Gone"},
131-
{code::LENGTH_REQUIRED, "Length Required"},
132-
{code::PRECONDITION_FAILED, "Precondition Failed"},
133-
{code::REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large"},
134-
{code::REQUEST_URI_TOO_LONG, "Request Uri Too Long"},
135-
{code::UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"},
136-
{code::REQUEST_RANGE_NOT_SATISFIABLE, "Request Range Not Satisfiable"},
137-
{code::EXPECTATION_FAILED, "Expectation Failed"},
138-
{code::PRECONDITION_REQUIRED, "Precondition Required"},
139-
{code::TOO_MANY_REQUESTS, "Too Many Requests"},
140-
{code::REQUEST_HEADER_FIELDS_TOO_LARGE, "Request Header Fields Too Large"},
141-
{code::INTERNAL_ERROR, "Internal Error"},
142-
{code::NOT_IMPLEMENTED, "Not Implemented"},
143-
{code::BAD_GATEWAY, "Bad Gateway"},
144-
{code::SERVICE_UNAVAILABLE, "Service Unavailable"},
145-
{code::GATEWAY_TIMEOUT, "Gateway Timeout"},
146-
{code::HTTP_VERSION_NOT_SUPPORTED, "HTTP Version Not Supported"},
147-
{code::NETWORK_AUTHENTICATION_REQUIRED, "Network Authentication Required"},
104+
{code::continue_, "Continue"},
105+
{code::switch_protocols, "Switching Protocols"},
106+
{code::ok, "OK"},
107+
{code::created, "Created"},
108+
{code::accepted, "Accepted"},
109+
{code::non_auth_info, "Non-Authoritative Information"},
110+
{code::no_content, "No Content"},
111+
{code::reset_content, "Reset Content"},
112+
{code::partial_content, "Partial Content"},
113+
{code::multiple_choices, "Multiple Choices"},
114+
{code::moved_permanently, "Moved Permanently"},
115+
{code::found, "Found"},
116+
{code::see_other, "See Other"},
117+
{code::not_modified, "Not Modified"},
118+
{code::use_proxy, "Use Proxy"},
119+
{code::temporary_redirect, "Temporary Redirect"},
120+
{code::bad_request, "Bad Request"},
121+
{code::unauthorized, "Unauthorized"},
122+
{code::payment_required, "Payment Required"},
123+
{code::forbidden, "Forbidden"},
124+
{code::not_found, "Not Found"},
125+
{code::method_not_allowed, "Method Not Allowed"},
126+
{code::not_acceptable, "Not Acceptable"},
127+
{code::proxy_auth_required, "Proxy Authentication Required"},
128+
{code::request_timeout, "Request Timeout"},
129+
{code::conflict, "Conflict"},
130+
{code::gone, "Gone"},
131+
{code::length_required, "Length Required"},
132+
{code::precondition_failed, "Precondition Failed"},
133+
{code::request_entity_too_large, "Request Entity Too Large"},
134+
{code::request_uri_too_long, "Request Uri Too Long"},
135+
{code::unsupported_media_type, "Unsupported Media Type"},
136+
{code::request_range_not_satisfiable, "Request Range Not Satisfiable"},
137+
{code::expectation_failed, "Expectation Failed"},
138+
{code::precondition_required, "Precondition Required"},
139+
{code::too_many_requests, "Too Many Requests"},
140+
{code::request_header_fields_too_large, "Request Header Fields Too Large"},
141+
{code::internal_error, "Internal Error"},
142+
{code::not_implemented, "Not Implemented"},
143+
{code::bad_gateway, "Bad Gateway"},
144+
{code::service_unavailable, "Service Unavailable"},
145+
{code::gateway_timeout, "Gateway Timeout"},
146+
{code::http_version_not_supported, "HTTP Version Not Supported"},
147+
{code::network_authentication_required, "Network Authentication Required"},
148148
};
149149

150150
auto it = status_messages.find(status_code);

http/test/v2/features/client/client_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Describe(http_client) {
3232
auto response = future_response.get();
3333

3434
Assert::That(response.version(), Equals("HTTP/1.1"));
35-
Assert::That(response.status(), Equals(http::status::code::OK));
35+
Assert::That(response.status(), Equals(http::status::code::ok));
3636
Assert::That(response.status_message(), Equals("OK"));
3737

3838
auto headers = response.headers();

0 commit comments

Comments
 (0)