From 1475e3093038e2b2b9ad1b475c698b890241054e Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sun, 31 Mar 2013 09:24:15 -0500 Subject: [PATCH] updates http constants to match the code style of the rest of the library --- test/http/parser.cpp | 12 +- websocketpp/http/constants.hpp | 206 +++++++++++++-------------- websocketpp/http/impl/parser.hpp | 14 +- websocketpp/http/impl/request.hpp | 22 +-- websocketpp/http/impl/response.hpp | 22 +-- websocketpp/http/parser.hpp | 8 +- websocketpp/http/response.hpp | 2 +- websocketpp/impl/connection_impl.hpp | 27 ++-- 8 files changed, 157 insertions(+), 156 deletions(-) diff --git a/test/http/parser.cpp b/test/http/parser.cpp index f16ff3c560..c61fb3d624 100644 --- a/test/http/parser.cpp +++ b/test/http/parser.cpp @@ -509,7 +509,7 @@ BOOST_AUTO_TEST_CASE( basic_split2 ) { BOOST_AUTO_TEST_CASE( max_header_len ) { websocketpp::http::parser::request r; - std::string raw(websocketpp::http::MAX_HEADER_SIZE+1,'*'); + std::string raw(websocketpp::http::max_header_size+1,'*'); bool exception = false; size_t pos = 0; @@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE( max_header_len ) { try { pos += r.consume(raw.c_str(),raw.size()); } catch (const websocketpp::http::exception& e) { - if (e.m_error_code == websocketpp::http::status_code::REQUEST_HEADER_FIELDS_TOO_LARGE) { + if (e.m_error_code == websocketpp::http::status_code::request_header_fields_too_large) { exception = true; } } @@ -528,7 +528,7 @@ BOOST_AUTO_TEST_CASE( max_header_len ) { BOOST_AUTO_TEST_CASE( max_header_len_split ) { websocketpp::http::parser::request r; - std::string raw(websocketpp::http::MAX_HEADER_SIZE-1,'*'); + std::string raw(websocketpp::http::max_header_size-1,'*'); std::string raw2(2,'*'); bool exception = false; @@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE( max_header_len_split ) { pos += r.consume(raw.c_str(),raw.size()); pos += r.consume(raw2.c_str(),raw2.size()); } catch (const websocketpp::http::exception& e) { - if (e.m_error_code == websocketpp::http::status_code::REQUEST_HEADER_FIELDS_TOO_LARGE) { + if (e.m_error_code == websocketpp::http::status_code::request_header_fields_too_large) { exception = true; } } @@ -788,7 +788,7 @@ BOOST_AUTO_TEST_CASE( wikipedia_example_response ) { BOOST_CHECK( pos == 159 ); BOOST_CHECK( r.headers_ready() == true ); BOOST_CHECK( r.get_version() == "HTTP/1.1" ); - BOOST_CHECK( r.get_status_code() == websocketpp::http::status_code::SWITCHING_PROTOCOLS ); + BOOST_CHECK( r.get_status_code() == websocketpp::http::status_code::switching_protocols ); BOOST_CHECK( r.get_status_msg() == "Switching Protocols" ); BOOST_CHECK( r.get_header("Upgrade") == "websocket" ); BOOST_CHECK( r.get_header("Connection") == "Upgrade" ); @@ -816,7 +816,7 @@ BOOST_AUTO_TEST_CASE( plain_http_response ) { BOOST_CHECK( r.headers_ready() == true ); BOOST_CHECK( r.ready() == true ); BOOST_CHECK( r.get_version() == "HTTP/1.1" ); - BOOST_CHECK( r.get_status_code() == websocketpp::http::status_code::OK ); + BOOST_CHECK( r.get_status_code() == websocketpp::http::status_code::ok ); BOOST_CHECK( r.get_status_msg() == "OK" ); BOOST_CHECK( r.get_header("Date") == "Thu, 10 May 2012 11:59:25 GMT" ); BOOST_CHECK( r.get_header("Server") == "Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.8 with Suhosin-Patch" ); diff --git a/websocketpp/http/constants.hpp b/websocketpp/http/constants.hpp index a687f27c15..9463c568b4 100644 --- a/websocketpp/http/constants.hpp +++ b/websocketpp/http/constants.hpp @@ -32,17 +32,17 @@ namespace websocketpp { namespace http { - static const char HEADER_DELIMITER[] = "\r\n"; - static const char HEADER_SEPARATOR[] = ": "; - static const std::string EMPTY_HEADER = ""; + static const char header_delimiter[] = "\r\n"; + static const char header_separator[] = ": "; + static const std::string empty_header = ""; // Maximum size in bytes before rejecting an HTTP header as too big. - const size_t MAX_HEADER_SIZE = 16000; + const size_t max_header_size = 16000; // invalid HTTP token characters // 0x00 - 0x32, 0x7f-0xff // ( ) < > @ , ; : \ " / [ ] ? = { } - static const char HEADER_TOKEN[] = { + static const char header_token[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..0f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 10..1f 0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0, // 20..2f @@ -62,11 +62,11 @@ namespace http { }; inline bool is_token_char(unsigned char c) { - return (HEADER_TOKEN[c] == 1); + return (header_token[c] == 1); } inline bool is_not_token_char(unsigned char c) { - return !HEADER_TOKEN[c]; + return !header_token[c]; } // Space (32) or horizontal tab (9) @@ -80,159 +80,159 @@ namespace http { namespace status_code { enum value { - UNINITIALIZED = 0, + uninitialized = 0, - CONTINUE = 100, - SWITCHING_PROTOCOLS = 101, + continue_code = 100, + switching_protocols = 101, - OK = 200, - CREATED = 201, - ACCEPTED = 202, - NON_AUTHORITATIVE_INFORMATION = 203, - NO_CONTENT = 204, - RESET_CONTENT = 205, - PARTIAL_CONTENT = 206, + ok = 200, + created = 201, + accepted = 202, + non_authoritative_information = 203, + no_content = 204, + reset_content = 205, + partial_content = 206, - MULTIPLE_CHOICES = 300, - MOVED_PERMANENTLY = 301, - FOUND = 302, - SEE_OTHER = 303, - NOT_MODIFIED = 304, - USE_PROXY = 305, - TEMPORARY_REDIRECT = 307, + multiple_choices = 300, + moved_permanently = 301, + found = 302, + see_other = 303, + not_modified = 304, + use_proxy = 305, + temporary_redirect = 307, - BAD_REQUEST = 400, - UNAUTHORIZED = 401, - PAYMENT_REQUIRED = 402, - FORBIDDEN = 403, - NOT_FOUND = 404, - METHOD_NOT_ALLOWED = 405, - NOT_ACCEPTABLE = 406, - PROXY_AUTHENTICATION_REQUIRED = 407, - REQUEST_TIMEOUT = 408, - CONFLICT = 409, - GONE = 410, - LENGTH_REQUIRED = 411, - PRECONDITION_FAILED = 412, - REQUEST_ENTITY_TOO_LARGE = 413, - REQUEST_URI_TOO_LONG = 414, - UNSUPPORTED_MEDIA_TYPE = 415, - REQUEST_RANGE_NOT_SATISFIABLE = 416, - EXPECTATION_FAILED = 417, - IM_A_TEAPOT = 418, - UPGRADE_REQUIRED = 426, - PRECONDITION_REQUIRED = 428, - TOO_MANY_REQUESTS = 429, - REQUEST_HEADER_FIELDS_TOO_LARGE = 431, + bad_request = 400, + unauthorized = 401, + payment_required = 402, + forbidden = 403, + not_found = 404, + method_not_allowed = 405, + not_acceptable = 406, + proxy_authentication_required = 407, + request_timeout = 408, + conflict = 409, + gone = 410, + length_required = 411, + precondition_failed = 412, + request_entity_too_large = 413, + request_uri_too_long = 414, + unsupported_media_type = 415, + request_range_not_satisfiable = 416, + expectation_failed = 417, + im_a_teapot = 418, + upgrade_required = 426, + precondition_required = 428, + too_many_requests = 429, + request_header_fields_too_large = 431, - INTERNAL_SERVER_ERROR = 500, - NOT_IMPLIMENTED = 501, - BAD_GATEWAY = 502, - SERVICE_UNAVAILABLE = 503, - GATEWAY_TIMEOUT = 504, - HTTP_VERSION_NOT_SUPPORTED = 505, - NOT_EXTENDED = 510, - NETWORK_AUTHENTICATION_REQUIRED = 511 + internal_server_error = 500, + not_implimented = 501, + bad_gateway = 502, + service_unavailable = 503, + gateway_timeout = 504, + http_version_not_supported = 505, + not_extended = 510, + network_authentication_required = 511 }; // TODO: should this be inline? inline std::string get_string(value c) { switch (c) { - case UNINITIALIZED: + case uninitialized: return "Uninitialized"; - case CONTINUE: + case continue_code: return "Continue"; - case SWITCHING_PROTOCOLS: + case switching_protocols: return "Switching Protocols"; - case OK: + case ok: return "OK"; - case CREATED: + case created: return "Created"; - case ACCEPTED: + case accepted: return "Accepted"; - case NON_AUTHORITATIVE_INFORMATION: + case non_authoritative_information: return "Non Authoritative Information"; - case NO_CONTENT: + case no_content: return "No Content"; - case RESET_CONTENT: + case reset_content: return "Reset Content"; - case PARTIAL_CONTENT: + case partial_content: return "Partial Content"; - case MULTIPLE_CHOICES: + case multiple_choices: return "Multiple Choices"; - case MOVED_PERMANENTLY: + case moved_permanently: return "Moved Permanently"; - case FOUND: + case found: return "Found"; - case SEE_OTHER: + case see_other: return "See Other"; - case NOT_MODIFIED: + case not_modified: return "Not Modified"; - case USE_PROXY: + case use_proxy: return "Use Proxy"; - case TEMPORARY_REDIRECT: + case temporary_redirect: return "Temporary Redirect"; - case BAD_REQUEST: + case bad_request: return "Bad Request"; - case UNAUTHORIZED: + case unauthorized: return "Unauthorized"; - case PAYMENT_REQUIRED: + case payment_required: return "Payment Required"; - case FORBIDDEN: + case forbidden: return "Forbidden"; - case NOT_FOUND: + case not_found: return "Not Found"; - case METHOD_NOT_ALLOWED: + case method_not_allowed: return "Method Not Allowed"; - case NOT_ACCEPTABLE: + case not_acceptable: return "Not Acceptable"; - case PROXY_AUTHENTICATION_REQUIRED: + case proxy_authentication_required: return "Proxy Authentication Required"; - case REQUEST_TIMEOUT: + case request_timeout: return "Request Timeout"; - case CONFLICT: + case conflict: return "Conflict"; - case GONE: + case gone: return "Gone"; - case LENGTH_REQUIRED: + case length_required: return "Length Required"; - case PRECONDITION_FAILED: + case precondition_failed: return "Precondition Failed"; - case REQUEST_ENTITY_TOO_LARGE: + case request_entity_too_large: return "Request Entity Too Large"; - case REQUEST_URI_TOO_LONG: + case request_uri_too_long: return "Request-URI Too Long"; - case UNSUPPORTED_MEDIA_TYPE: + case unsupported_media_type: return "Unsupported Media Type"; - case REQUEST_RANGE_NOT_SATISFIABLE: + case request_range_not_satisfiable: return "Requested Range Not Satisfiable"; - case EXPECTATION_FAILED: + case expectation_failed: return "Expectation Failed"; - case IM_A_TEAPOT: + case im_a_teapot: return "I'm a teapot"; - case UPGRADE_REQUIRED: + case upgrade_required: return "Upgrade Required"; - case PRECONDITION_REQUIRED: + case precondition_required: return "Precondition Required"; - case TOO_MANY_REQUESTS: + case too_many_requests: return "Too Many Requests"; - case REQUEST_HEADER_FIELDS_TOO_LARGE: + case request_header_fields_too_large: return "Request Header Fields Too Large"; - case INTERNAL_SERVER_ERROR: + case internal_server_error: return "Internal Server Error"; - case NOT_IMPLIMENTED: + case not_implimented: return "Not Implimented"; - case BAD_GATEWAY: + case bad_gateway: return "Bad Gateway"; - case SERVICE_UNAVAILABLE: + case service_unavailable: return "Service Unavailable"; - case GATEWAY_TIMEOUT: + case gateway_timeout: return "Gateway Timeout"; - case HTTP_VERSION_NOT_SUPPORTED: + case http_version_not_supported: return "HTTP Version Not Supported"; - case NOT_EXTENDED: + case not_extended: return "Not Extended"; - case NETWORK_AUTHENTICATION_REQUIRED: + case network_authentication_required: return "Network Authentication Required"; default: return "Unknown"; diff --git a/websocketpp/http/impl/parser.hpp b/websocketpp/http/impl/parser.hpp index bbb535146e..75931d9c03 100644 --- a/websocketpp/http/impl/parser.hpp +++ b/websocketpp/http/impl/parser.hpp @@ -77,7 +77,7 @@ inline const std::string& parser::get_header(const std::string& key) const { header_list::const_iterator h = m_headers.find(key); if (h == m_headers.end()) { - return EMPTY_HEADER; + return empty_header; } else { return h->second; } @@ -87,7 +87,7 @@ inline void parser::append_header(const std::string &key,const std::string &val) { if (std::find_if(key.begin(),key.end(),is_not_token_char) != key.end()) { - throw exception("Invalid header name",status_code::BAD_REQUEST); + throw exception("Invalid header name",status_code::bad_request); } // TODO: prevent use of reserved headers? @@ -133,7 +133,7 @@ inline bool parser::parse_headers(std::istream& s) { header.erase(header.end()-1); } - end = header.find(HEADER_SEPARATOR,0); + end = header.find(header_separator,0); if (end != std::string::npos) { append_header(header.substr(0,end),header.substr(end+2)); @@ -160,16 +160,16 @@ inline void parser::process_header(std::string::iterator begin, std::string::iterator cursor = std::search( begin, end, - HEADER_SEPARATOR, - HEADER_SEPARATOR + sizeof(HEADER_SEPARATOR) - 1 + header_separator, + header_separator + sizeof(header_separator) - 1 ); if (cursor == end) { - throw exception("Invalid header line",status_code::BAD_REQUEST); + throw exception("Invalid header line",status_code::bad_request); } append_header(std::string(begin,cursor), - std::string(cursor+sizeof(HEADER_SEPARATOR)-1,end)); + std::string(cursor+sizeof(header_separator)-1,end)); } } // namespace parser diff --git a/websocketpp/http/impl/request.hpp b/websocketpp/http/impl/request.hpp index d4b697b8e2..f1a6fd0239 100644 --- a/websocketpp/http/impl/request.hpp +++ b/websocketpp/http/impl/request.hpp @@ -67,10 +67,10 @@ inline bool request::parse_complete(std::istream& s) { inline size_t request::consume(const char *buf, size_t len) { if (m_ready) {return 0;} - if (m_buf->size() + len > MAX_HEADER_SIZE) { + if (m_buf->size() + len > max_header_size) { // exceeded max header size throw exception("Maximum header size exceeded.", - status_code::REQUEST_HEADER_FIELDS_TOO_LARGE); + status_code::request_header_fields_too_large); } // copy new header bytes into buffer @@ -85,12 +85,12 @@ inline size_t request::consume(const char *buf, size_t len) { end = std::search( begin, m_buf->end(), - HEADER_DELIMITER, - HEADER_DELIMITER+sizeof(HEADER_DELIMITER)-1 + header_delimiter, + header_delimiter+sizeof(header_delimiter)-1 ); //std::cout << "mark5: " << end-begin << std::endl; - //std::cout << "mark6: " << sizeof(HEADER_DELIMITER) << std::endl; + //std::cout << "mark6: " << sizeof(header_delimiter) << std::endl; if (end == m_buf->end()) { // we are out of bytes. Discard the processed bytes and copy the @@ -105,13 +105,13 @@ inline size_t request::consume(const char *buf, size_t len) { if (end-begin == 0) { // we got a blank line if (m_method.empty() || get_header("Host") == "") { - throw exception("Incomplete Request",status_code::BAD_REQUEST); + throw exception("Incomplete Request",status_code::bad_request); } m_ready = true; size_t bytes_processed = ( len - static_cast(m_buf->end()-end) - + sizeof(HEADER_DELIMITER) - 1 + + sizeof(header_delimiter) - 1 ); // frees memory used temporarily during request parsing @@ -127,7 +127,7 @@ inline size_t request::consume(const char *buf, size_t len) { } } - begin = end+sizeof(HEADER_DELIMITER)-1; + begin = end+sizeof(header_delimiter)-1; } } @@ -143,7 +143,7 @@ inline std::string request::raw() { inline void request::set_method(const std::string& method) { if (std::find_if(method.begin(),method.end(),is_not_token_char) != method.end()) { - throw exception("Invalid method token.",status_code::BAD_REQUEST); + throw exception("Invalid method token.",status_code::bad_request); } m_method = method; @@ -161,7 +161,7 @@ inline void request::process(std::string::iterator begin, std::string::iterator std::string::iterator cursor_end = std::find(begin,end,' '); if (cursor_end == end) { - throw exception("Invalid request line1",status_code::BAD_REQUEST); + throw exception("Invalid request line1",status_code::bad_request); } set_method(std::string(cursor_start,cursor_end)); @@ -170,7 +170,7 @@ inline void request::process(std::string::iterator begin, std::string::iterator cursor_end = std::find(cursor_start,end,' '); if (cursor_end == end) { - throw exception("Invalid request line2",status_code::BAD_REQUEST); + throw exception("Invalid request line2",status_code::bad_request); } set_uri(std::string(cursor_start,cursor_end)); diff --git a/websocketpp/http/impl/response.hpp b/websocketpp/http/impl/response.hpp index b3e0a18f4c..08b2eb9217 100644 --- a/websocketpp/http/impl/response.hpp +++ b/websocketpp/http/impl/response.hpp @@ -44,10 +44,10 @@ inline size_t response::consume(const char *buf, size_t len) { return this->process_body(buf,len); } - if (m_read + len > MAX_HEADER_SIZE) { + if (m_read + len > max_header_size) { // exceeded max header size throw exception("Maximum header size exceeded.", - status_code::REQUEST_HEADER_FIELDS_TOO_LARGE); + status_code::request_header_fields_too_large); } // copy new header bytes into buffer @@ -63,8 +63,8 @@ inline size_t response::consume(const char *buf, size_t len) { end = std::search( begin, m_buf->end(), - HEADER_DELIMITER, - HEADER_DELIMITER + sizeof(HEADER_DELIMITER) - 1 + header_delimiter, + header_delimiter + sizeof(header_delimiter) - 1 ); if (end == m_buf->end()) { @@ -83,7 +83,7 @@ inline size_t response::consume(const char *buf, size_t len) { if (end-begin == 0) { // we got a blank line if (m_state == RESPONSE_LINE) { - throw exception("Incomplete Request",status_code::BAD_REQUEST); + throw exception("Incomplete Request",status_code::bad_request); } // TODO: grab content-length @@ -97,7 +97,7 @@ inline size_t response::consume(const char *buf, size_t len) { if ((ss >> m_read).fail()) { throw exception("Unable to parse Content-Length header", - status_code::BAD_REQUEST); + status_code::bad_request); } } @@ -106,7 +106,7 @@ inline size_t response::consume(const char *buf, size_t len) { // calc header bytes processed (starting bytes - bytes left) size_t read = ( len - static_cast(m_buf->end() - end) - + sizeof(HEADER_DELIMITER) - 1 + + sizeof(header_delimiter) - 1 ); // if there were bytes left process them as body bytes @@ -127,7 +127,7 @@ inline size_t response::consume(const char *buf, size_t len) { } } - begin = end+sizeof(HEADER_DELIMITER) - 1; + begin = end+sizeof(header_delimiter) - 1; } } @@ -193,7 +193,7 @@ inline void response::process(std::string::iterator begin, std::string::iterator cursor_end = std::find(begin,end,' '); if (cursor_end == end) { - throw exception("Invalid response line",status_code::BAD_REQUEST); + throw exception("Invalid response line",status_code::bad_request); } set_version(std::string(cursor_start,cursor_end)); @@ -202,7 +202,7 @@ inline void response::process(std::string::iterator begin, cursor_end = std::find(cursor_start,end,' '); if (cursor_end == end) { - throw exception("Invalid request line",status_code::BAD_REQUEST); + throw exception("Invalid request line",status_code::bad_request); } int code; @@ -210,7 +210,7 @@ inline void response::process(std::string::iterator begin, std::istringstream ss(std::string(cursor_start,cursor_end)); if ((ss >> code).fail()) { - throw exception("Unable to parse response code",status_code::BAD_REQUEST); + throw exception("Unable to parse response code",status_code::bad_request); } set_status(status_code::value(code),std::string(cursor_end+1,end)); diff --git a/websocketpp/http/parser.hpp b/websocketpp/http/parser.hpp index ddf5439833..8b601c9c74 100644 --- a/websocketpp/http/parser.hpp +++ b/websocketpp/http/parser.hpp @@ -40,10 +40,10 @@ namespace parser { namespace state { enum value { - METHOD, - RESOURCE, - VERSION, - HEADERS + method, + resource, + version, + headers }; } diff --git a/websocketpp/http/response.hpp b/websocketpp/http/response.hpp index c31ef199b3..da29e4f69c 100644 --- a/websocketpp/http/response.hpp +++ b/websocketpp/http/response.hpp @@ -56,7 +56,7 @@ public: response() : m_read(0) , m_buf(new std::string()) - , m_status_code(status_code::UNINITIALIZED) + , m_status_code(status_code::uninitialized) , m_state(RESPONSE_LINE) {} /// Process bytes in the input buffer diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 32171cdcb3..c39b6a9db0 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -567,7 +567,7 @@ void connection::handle_handshake_read(const lib::error_code& ec, } else { // TODO: need more bytes m_alog.write(log::alevel::devel,"short key3 read"); - m_response.set_status(http::status_code::INTERNAL_SERVER_ERROR); + m_response.set_status(http::status_code::internal_server_error); this->send_http_response_error(); return; } @@ -744,7 +744,7 @@ bool connection::initialize_processor() { if (version < 0) { m_alog.write(log::alevel::devel, "BAD REQUEST: can't determine version"); - m_response.set_status(http::status_code::BAD_REQUEST); + m_response.set_status(http::status_code::bad_request); return false; } @@ -759,7 +759,7 @@ bool connection::initialize_processor() { // with Sec-WebSocket-Version header filled with values we do accept m_alog.write(log::alevel::devel, "BAD REQUEST: no processor for version"); - m_response.set_status(http::status_code::BAD_REQUEST); + m_response.set_status(http::status_code::bad_request); std::stringstream ss; std::string sep = ""; @@ -796,7 +796,7 @@ bool connection::process_handshake_request() { // Not a valid handshake request m_alog.write(log::alevel::devel, "BAD REQUEST (724) "+ec.message()); - m_response.set_status(http::status_code::BAD_REQUEST); + m_response.set_status(http::status_code::bad_request); return false; } @@ -810,7 +810,7 @@ bool connection::process_handshake_request() { // a failed connection attempt. m_alog.write(log::alevel::devel, "BAD REQUEST: (737) " + neg_results.first.message()); - m_response.set_status(http::status_code::BAD_REQUEST); + m_response.set_status(http::status_code::bad_request); return false; } else { // extension negotiation succeded, set response header accordingly @@ -828,13 +828,13 @@ bool connection::process_handshake_request() { } catch (const websocketpp::uri_exception& e) { m_alog.write(log::alevel::devel, std::string("BAD REQUEST: uri failed to parse: ")+e.what()); - m_response.set_status(http::status_code::BAD_REQUEST); + m_response.set_status(http::status_code::bad_request); return false; } // Ask application to validate the connection if (!m_validate_handler || m_validate_handler(m_connection_hdl)) { - m_response.set_status(http::status_code::SWITCHING_PROTOCOLS); + m_response.set_status(http::status_code::switching_protocols); // Write the appropriate response headers based on request and // processor version @@ -845,7 +845,7 @@ bool connection::process_handshake_request() { s << "Processing error: " << ec << "(" << ec.message() << ")"; m_alog.write(log::alevel::devel,s.str()); - m_response.set_status(http::status_code::INTERNAL_SERVER_ERROR); + m_response.set_status(http::status_code::internal_server_error); return false; } } else { @@ -855,8 +855,8 @@ bool connection::process_handshake_request() { // Use Bad Request if the user handler did not provide a more // specific http response error code. // TODO: is there a better default? - if (m_response.get_status_code() == http::status_code::UNINITIALIZED) { - m_response.set_status(http::status_code::BAD_REQUEST); + if (m_response.get_status_code() == http::status_code::uninitialized) { + m_response.set_status(http::status_code::bad_request); } return false; @@ -924,8 +924,8 @@ template void connection::send_http_response() { m_alog.write(log::alevel::devel,"connection send_http_response"); - if (m_response.get_status_code() == http::status_code::UNINITIALIZED) { - m_response.set_status(http::status_code::INTERNAL_SERVER_ERROR); + if (m_response.get_status_code() == http::status_code::uninitialized) { + m_response.set_status(http::status_code::internal_server_error); } m_response.set_version("HTTP/1.1"); @@ -977,7 +977,7 @@ void connection::handle_send_http_response( this->log_open_result(); - if (m_response.get_status_code() != http::status_code::SWITCHING_PROTOCOLS) + if (m_response.get_status_code() != http::status_code::switching_protocols) { if (m_processor) { // if this was not a websocket connection, we have written @@ -1122,6 +1122,7 @@ void connection::handle_read_http_response(const lib::error_code& ec, if (m_response.ready()) { // process + // } else { transport_con_type::async_read_at_least( 1,