Merge branch 'pr/468' into develop
This commit is contained in:
commit
536db87c53
25 files changed
+97
-94
No files matched your search
@@ -19,6 +19,9 @@ HEAD
|
||||
and `connection::get_response_msg` methods to allow accessing additional
|
||||
information about the HTTP responses that WebSocket++ sends. #465 Thank you
|
||||
Flow86 for reporting.
|
||||
- Improvement: Removes use of empty strings ("") in favor of `string::clear()`
|
||||
and `string::empty()`. This avoids generating unnecessary temporary objects.
|
||||
#468 Thank you Vladislav Yaroslavlev for reporting and a patch.
|
||||
- Documentation: Adds an example demonstrating the use of external `io_service`
|
||||
- Bug: Fix memory leak when init_asio produces an error. #454 Thank you Mark
|
||||
Grimes for reporting and fixing.
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
connection_data data;
|
||||
|
||||
data.sessionid = m_next_sessionid++;
|
||||
data.name = "";
|
||||
data.name.clear();
|
||||
|
||||
m_connections[hdl] = data;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
void on_message(connection_hdl hdl, server::message_ptr msg) {
|
||||
connection_data& data = get_data_from_hdl(hdl);
|
||||
|
||||
if (data.name == "") {
|
||||
if (data.name.empty()) {
|
||||
data.name = msg->get_payload();
|
||||
std::cout << "Setting name of connection with sessionid "
|
||||
<< data.sessionid << " to " << data.name << std::endl;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void on_message(connection_hdl hdl, server::message_ptr msg) {
|
||||
connection_ptr con = m_server.get_con_from_hdl(hdl);
|
||||
|
||||
if (con->name == "") {
|
||||
if (con->name.empty()) {
|
||||
con->name = msg->get_payload();
|
||||
std::cout << "Setting name of connection with sessionid "
|
||||
<< con->sessionid << " to " << con->name << std::endl;
|
||||
|
||||
@@ -246,7 +246,7 @@ int main() {
|
||||
std::string cmd;
|
||||
int id;
|
||||
int close_code = websocketpp::close::status::normal;
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
|
||||
ss >> cmd >> id >> close_code;
|
||||
std::getline(ss,reason);
|
||||
|
||||
@@ -289,7 +289,7 @@ int main() {
|
||||
|
||||
std::string cmd;
|
||||
int id;
|
||||
std::string message = "";
|
||||
std::string message;
|
||||
|
||||
ss >> cmd >> id;
|
||||
std::getline(ss,message);
|
||||
@@ -301,7 +301,7 @@ int main() {
|
||||
std::string cmd;
|
||||
int id;
|
||||
int close_code = websocketpp::close::status::normal;
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
|
||||
ss >> cmd >> id >> close_code;
|
||||
std::getline(ss,reason);
|
||||
|
||||
@@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE( negotiate_server_no_context_takeover_invalid ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( negotiate_server_no_context_takeover ) {
|
||||
ext_vars v;
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
BOOST_CHECK( v.exts.is_enabled() );
|
||||
@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE( negotiate_client_no_context_takeover_invalid ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( negotiate_client_no_context_takeover ) {
|
||||
ext_vars v;
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
BOOST_CHECK( v.exts.is_enabled() );
|
||||
@@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_invalid ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_valid ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["client_max_window_bits"] = "";
|
||||
v.attr["client_max_window_bits"].clear();
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
BOOST_CHECK( v.exts.is_enabled() );
|
||||
BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
|
||||
@@ -364,8 +364,8 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_smallest ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated1 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
BOOST_CHECK( v.exts.is_enabled() );
|
||||
@@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated1 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated2 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated2 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated3 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -400,7 +400,7 @@ BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated3 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated4 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated4 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated5 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -436,8 +436,8 @@ BOOST_AUTO_TEST_CASE( negotiate_two_client_initiated6 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated1 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -449,8 +449,8 @@ BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated1 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated2 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
v.esp = v.exts.negotiate(v.attr);
|
||||
@@ -462,7 +462,7 @@ BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated2 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated3 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
@@ -475,7 +475,7 @@ BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated3 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated4 ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
@@ -488,8 +488,8 @@ BOOST_AUTO_TEST_CASE( negotiate_three_client_initiated4 ) {
|
||||
BOOST_AUTO_TEST_CASE( negotiate_four_client_initiated ) {
|
||||
ext_vars v;
|
||||
|
||||
v.attr["server_no_context_takeover"] = "";
|
||||
v.attr["client_no_context_takeover"] = "";
|
||||
v.attr["server_no_context_takeover"].clear();
|
||||
v.attr["client_no_context_takeover"].clear();
|
||||
v.attr["server_max_window_bits"] = "10";
|
||||
v.attr["client_max_window_bits"] = "10";
|
||||
|
||||
@@ -569,7 +569,7 @@ BOOST_AUTO_TEST_CASE( compress_data_no_context_takeover ) {
|
||||
|
||||
websocketpp::http::attribute_list alist;
|
||||
|
||||
alist["server_no_context_takeover"] = "";
|
||||
alist["server_no_context_takeover"].clear();
|
||||
v.exts.enable_server_no_context_takeover();
|
||||
|
||||
v.exts.negotiate(alist);
|
||||
@@ -586,7 +586,7 @@ BOOST_AUTO_TEST_CASE( compress_data_no_context_takeover ) {
|
||||
BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
|
||||
BOOST_CHECK_EQUAL( compress_in, decompress_out );
|
||||
|
||||
decompress_out = "";
|
||||
decompress_out.clear();
|
||||
|
||||
v.ec = v.exts.compress(compress_in,compress_out2);
|
||||
BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
|
||||
@@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE( compress_data_no_context_takeover ) {
|
||||
BOOST_AUTO_TEST_CASE( compress_empty ) {
|
||||
ext_vars v;
|
||||
|
||||
std::string compress_in = "";
|
||||
std::string compress_in;
|
||||
std::string compress_out;
|
||||
std::string decompress_out;
|
||||
|
||||
@@ -616,8 +616,8 @@ BOOST_AUTO_TEST_CASE( compress_empty ) {
|
||||
|
||||
v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
|
||||
|
||||
compress_out = "";
|
||||
decompress_out = "";
|
||||
compress_out.clear();
|
||||
decompress_out.clear();
|
||||
|
||||
v.ec = v.exts.compress(compress_in,compress_out);
|
||||
BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
|
||||
@@ -637,7 +637,7 @@ BOOST_AUTO_TEST_CASE( decompress_data ) {
|
||||
ext_vars v;
|
||||
|
||||
uint8_t in[11] = {0xf2, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff};
|
||||
std::string out = "";
|
||||
std::string out;
|
||||
std::string reference = "Hello";
|
||||
|
||||
v.exts.init(true);
|
||||
|
||||
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE( extract_token ) {
|
||||
BOOST_CHECK( ret.second == d1.begin()+3 );
|
||||
|
||||
ret = websocketpp::http::parser::extract_token(d2.begin(),d2.end());
|
||||
BOOST_CHECK( ret.first == "" );
|
||||
BOOST_CHECK( ret.first.empty() );
|
||||
BOOST_CHECK( ret.second == d2.begin()+0 );
|
||||
|
||||
ret = websocketpp::http::parser::extract_token(d2.begin()+1,d2.end());
|
||||
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE( extract_quoted_string ) {
|
||||
std::string d1 = "\"foo\"";
|
||||
std::string d2 = "\"foo\\\"bar\\\"baz\"";
|
||||
std::string d3 = "\"foo\" ";
|
||||
std::string d4 = "";
|
||||
std::string d4;
|
||||
std::string d5 = "foo";
|
||||
|
||||
std::pair<std::string,std::string::const_iterator> ret;
|
||||
@@ -147,11 +147,11 @@ BOOST_AUTO_TEST_CASE( extract_quoted_string ) {
|
||||
BOOST_CHECK( ret.second == d3.begin()+5 );
|
||||
|
||||
ret = extract_quoted_string(d4.begin(),d4.end());
|
||||
BOOST_CHECK( ret.first == "" );
|
||||
BOOST_CHECK( ret.first.empty() );
|
||||
BOOST_CHECK( ret.second == d4.begin() );
|
||||
|
||||
ret = extract_quoted_string(d5.begin(),d5.end());
|
||||
BOOST_CHECK( ret.first == "" );
|
||||
BOOST_CHECK( ret.first.empty() );
|
||||
BOOST_CHECK( ret.second == d5.begin() );
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE( extract_all_lws ) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( extract_attributes_blank ) {
|
||||
std::string s = "";
|
||||
std::string s;
|
||||
|
||||
websocketpp::http::attribute_list a;
|
||||
std::string::const_iterator it;
|
||||
@@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE( extract_attributes_simple ) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( extract_parameters ) {
|
||||
std::string s1 = "";
|
||||
std::string s1;
|
||||
std::string s2 = "foo";
|
||||
std::string s3 = " foo \r\nAbc";
|
||||
std::string s4 = " \r\n foo ";
|
||||
@@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE( case_insensitive_headers_overwrite ) {
|
||||
BOOST_AUTO_TEST_CASE( blank_consume ) {
|
||||
websocketpp::http::parser::request r;
|
||||
|
||||
std::string raw = "";
|
||||
std::string raw;
|
||||
|
||||
bool exception = false;
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE( deflate_init ) {
|
||||
<< websocketpp::utility::to_hex(test_out,test_out_size) << std::endl;
|
||||
|
||||
std::string input = "Hello";
|
||||
std::string output = "";
|
||||
std::string output;
|
||||
ec = de.compress(input,output);
|
||||
|
||||
BOOST_CHECK( ec == processor::extensions::error::uninitialized );
|
||||
@@ -181,7 +181,7 @@ BOOST_AUTO_TEST_CASE( deflate_init ) {
|
||||
<< websocketpp::utility::to_hex(input) << std::endl
|
||||
<< websocketpp::utility::to_hex(output) << std::endl;
|
||||
|
||||
output = "";
|
||||
output.clear();
|
||||
|
||||
ec = de.compress(input,output);
|
||||
std::cout << ec.message() << std::endl
|
||||
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE( deflate_init ) {
|
||||
<< websocketpp::utility::to_hex(output) << std::endl;
|
||||
|
||||
input = output;
|
||||
output = "";
|
||||
output.clear();
|
||||
ec = de.decompress(input,output);
|
||||
std::cout << ec.message() << std::endl
|
||||
<< websocketpp::utility::to_hex(input) << std::endl
|
||||
|
||||
@@ -103,7 +103,7 @@ bool validate_func_subprotocol(server* s, std::string* out, std::string accept,
|
||||
|
||||
*out = o.str();
|
||||
|
||||
if (accept != "") {
|
||||
if (!accept.empty()) {
|
||||
con->select_subprotocol(accept);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE( value_extraction ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( extract_empty ) {
|
||||
lib::error_code ec;
|
||||
std::string payload = "";
|
||||
std::string payload;
|
||||
|
||||
BOOST_CHECK( close::extract_code(payload,ec) == close::status::no_status );
|
||||
BOOST_CHECK( !ec );
|
||||
@@ -109,12 +109,12 @@ BOOST_AUTO_TEST_CASE( extract_reason ) {
|
||||
BOOST_CHECK( close::extract_reason(payload,ec) == "Foo" );
|
||||
BOOST_CHECK( !ec );
|
||||
|
||||
payload = "";
|
||||
BOOST_CHECK( close::extract_reason(payload,ec) == "" );
|
||||
payload.clear();
|
||||
BOOST_CHECK( close::extract_reason(payload,ec).empty() );
|
||||
BOOST_CHECK( !ec );
|
||||
|
||||
payload = "00";
|
||||
BOOST_CHECK( close::extract_reason(payload,ec) == "" );
|
||||
BOOST_CHECK( close::extract_reason(payload,ec).empty() );
|
||||
BOOST_CHECK( !ec );
|
||||
|
||||
payload = "000";
|
||||
|
||||
@@ -246,7 +246,7 @@ int main() {
|
||||
std::string cmd;
|
||||
int id;
|
||||
int close_code = websocketpp::close::status::normal;
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
|
||||
ss >> cmd >> id >> close_code;
|
||||
std::getline(ss,reason);
|
||||
|
||||
@@ -289,7 +289,7 @@ int main() {
|
||||
|
||||
std::string cmd;
|
||||
int id;
|
||||
std::string message = "";
|
||||
std::string message;
|
||||
|
||||
ss >> cmd >> id;
|
||||
std::getline(ss,message);
|
||||
@@ -301,7 +301,7 @@ int main() {
|
||||
std::string cmd;
|
||||
int id;
|
||||
int close_code = websocketpp::close::status::normal;
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
|
||||
ss >> cmd >> id >> close_code;
|
||||
std::getline(ss,reason);
|
||||
|
||||
@@ -602,7 +602,7 @@ else if (input.substr(0,5) == "close") {
|
||||
std::string cmd;
|
||||
int id;
|
||||
int close_code = websocketpp::close::status::normal;
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
|
||||
ss >> cmd >> id >> close_code;
|
||||
std::getline(ss,reason);
|
||||
|
||||
@@ -322,7 +322,7 @@ inline status::value extract_code(std::string const & payload, lib::error_code
|
||||
inline std::string extract_reason(std::string const & payload, lib::error_code
|
||||
& ec)
|
||||
{
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
ec = lib::error_code();
|
||||
|
||||
if (payload.size() > 2) {
|
||||
|
||||
@@ -1385,7 +1385,7 @@ private:
|
||||
* @return A status code, zero on success, non-zero otherwise
|
||||
*/
|
||||
lib::error_code send_close_ack(close::status::value code =
|
||||
close::status::blank, std::string const & reason = "");
|
||||
close::status::blank, std::string const & reason = std::string());
|
||||
|
||||
/// Send close frame
|
||||
/**
|
||||
@@ -1403,7 +1403,7 @@ private:
|
||||
* @return A status code, zero on success, non-zero otherwise
|
||||
*/
|
||||
lib::error_code send_close_frame(close::status::value code =
|
||||
close::status::blank, std::string const & reason = "", bool ack = false,
|
||||
close::status::blank, std::string const & reason = std::string(), bool ack = false,
|
||||
bool terminal = false);
|
||||
|
||||
/// Get a pointer to a new WebSocket protocol processor for a given version
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace http {
|
||||
static char const header_separator[] = ":";
|
||||
|
||||
/// Literal value of an empty header
|
||||
static std::string const empty_header = "";
|
||||
static std::string const empty_header;
|
||||
|
||||
/// Maximum size in bytes before rejecting an HTTP header as too big.
|
||||
size_t const max_header_size = 16000;
|
||||
@@ -284,8 +284,8 @@ namespace http {
|
||||
public:
|
||||
exception(const std::string& log_msg,
|
||||
status_code::value error_code,
|
||||
const std::string& error_msg = "",
|
||||
const std::string& body = "")
|
||||
const std::string& error_msg = std::string(),
|
||||
const std::string& body = std::string())
|
||||
: m_msg(log_msg)
|
||||
, m_error_msg(error_msg)
|
||||
, m_body(body)
|
||||
|
||||
@@ -71,7 +71,7 @@ inline void parser::append_header(std::string const & key, std::string const &
|
||||
throw exception("Invalid header name",status_code::bad_request);
|
||||
}
|
||||
|
||||
if (this->get_header(key) == "") {
|
||||
if (this->get_header(key).empty()) {
|
||||
m_headers[key] = val;
|
||||
} else {
|
||||
m_headers[key] += ", " + val;
|
||||
@@ -91,7 +91,7 @@ inline void parser::remove_header(std::string const & key) {
|
||||
inline void parser::set_body(std::string const & value) {
|
||||
if (value.size() == 0) {
|
||||
remove_header("Content-Length");
|
||||
m_body = "";
|
||||
m_body.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ inline bool parser::parse_parameter_list(std::string const & in,
|
||||
}
|
||||
|
||||
inline bool parser::prepare_body() {
|
||||
if (get_header("Content-Length") != "") {
|
||||
if (!get_header("Content-Length").empty()) {
|
||||
std::string const & cl_header = get_header("Content-Length");
|
||||
char * end;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ inline size_t request::consume(char const * buf, size_t len) {
|
||||
//the range [begin,end) now represents a line to be processed.
|
||||
if (end-begin == 0) {
|
||||
// we got a blank line
|
||||
if (m_method.empty() || get_header("Host") == "") {
|
||||
if (m_method.empty() || get_header("Host").empty()) {
|
||||
throw exception("Incomplete Request",status_code::bad_request);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ inline size_t response::consume(char const * buf, size_t len) {
|
||||
// TODO: grab content-length
|
||||
std::string length = get_header("Content-Length");
|
||||
|
||||
if (length == "") {
|
||||
if (length.empty()) {
|
||||
// no content length found, read indefinitely
|
||||
m_read = 0;
|
||||
} else {
|
||||
|
||||
@@ -230,7 +230,7 @@ InputIterator extract_attributes(InputIterator begin, InputIterator end,
|
||||
cursor = http::parser::extract_all_lws(cursor,end);
|
||||
ret = http::parser::extract_token(cursor,end);
|
||||
|
||||
if (ret.first == "") {
|
||||
if (ret.first.empty()) {
|
||||
// error: expected a token
|
||||
return begin;
|
||||
} else {
|
||||
@@ -242,7 +242,7 @@ InputIterator extract_attributes(InputIterator begin, InputIterator end,
|
||||
if (cursor == end || *cursor != '=') {
|
||||
// if there is an equals sign, read the attribute value. Otherwise
|
||||
// record a blank value and continue
|
||||
attributes[name] = "";
|
||||
attributes[name].clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ InputIterator extract_attributes(InputIterator begin, InputIterator end,
|
||||
}
|
||||
|
||||
ret = http::parser::extract_token(cursor,end);
|
||||
if (ret.first == "") {
|
||||
if (ret.first.empty()) {
|
||||
// error : expected token or quoted string
|
||||
return begin;
|
||||
} else {
|
||||
@@ -321,7 +321,7 @@ InputIterator extract_parameters(InputIterator begin, InputIterator end,
|
||||
|
||||
ret = http::parser::extract_token(cursor,end);
|
||||
|
||||
if (ret.first == "") {
|
||||
if (ret.first.empty()) {
|
||||
// error: expected a token
|
||||
return begin;
|
||||
} else {
|
||||
|
||||
@@ -900,7 +900,7 @@ void connection<config>::handle_read_handshake(lib::error_code const & ec,
|
||||
|
||||
if (m_alog.static_test(log::alevel::devel)) {
|
||||
m_alog.write(log::alevel::devel,m_request.raw());
|
||||
if (m_request.get_header("Sec-WebSocket-Key3") != "") {
|
||||
if (!m_request.get_header("Sec-WebSocket-Key3").empty()) {
|
||||
m_alog.write(log::alevel::devel,
|
||||
utility::to_hex(m_request.get_header("Sec-WebSocket-Key3")));
|
||||
}
|
||||
@@ -1160,7 +1160,7 @@ lib::error_code connection<config>::initialize_processor() {
|
||||
m_response.set_status(http::status_code::bad_request);
|
||||
|
||||
std::stringstream ss;
|
||||
std::string sep = "";
|
||||
std::string sep;
|
||||
std::vector<int>::const_iterator it;
|
||||
for (it = versions_supported.begin(); it != versions_supported.end(); it++)
|
||||
{
|
||||
@@ -1308,7 +1308,7 @@ void connection<config>::write_http_response(lib::error_code const & ec) {
|
||||
m_response.set_version("HTTP/1.1");
|
||||
|
||||
// Set server header based on the user agent settings
|
||||
if (m_response.get_header("Server") == "") {
|
||||
if (m_response.get_header("Server").empty()) {
|
||||
if (!m_user_agent.empty()) {
|
||||
m_response.replace_header("Server",m_user_agent);
|
||||
} else {
|
||||
@@ -1326,7 +1326,7 @@ void connection<config>::write_http_response(lib::error_code const & ec) {
|
||||
|
||||
if (m_alog.static_test(log::alevel::devel)) {
|
||||
m_alog.write(log::alevel::devel,"Raw Handshake response:\n"+m_handshake_buffer);
|
||||
if (m_response.get_header("Sec-WebSocket-Key3") != "") {
|
||||
if (!m_response.get_header("Sec-WebSocket-Key3").empty()) {
|
||||
m_alog.write(log::alevel::devel,
|
||||
utility::to_hex(m_response.get_header("Sec-WebSocket-Key3")));
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ void connection<config>::send_http_request() {
|
||||
}
|
||||
|
||||
// Unless the user has overridden the user agent, send generic WS++ UA.
|
||||
if (m_request.get_header("User-Agent") == "") {
|
||||
if (m_request.get_header("User-Agent").empty()) {
|
||||
if (!m_user_agent.empty()) {
|
||||
m_request.replace_header("User-Agent",m_user_agent);
|
||||
} else {
|
||||
@@ -2075,7 +2075,7 @@ lib::error_code connection<config>::send_close_frame(close::status::value code,
|
||||
if (config::silent_close) {
|
||||
m_alog.write(log::alevel::devel,"closing silently");
|
||||
m_local_close_code = close::status::no_status;
|
||||
m_local_close_reason = "";
|
||||
m_local_close_reason.clear();
|
||||
} else if (code != close::status::blank) {
|
||||
m_alog.write(log::alevel::devel,"closing with specified codes");
|
||||
m_local_close_code = code;
|
||||
@@ -2083,12 +2083,12 @@ lib::error_code connection<config>::send_close_frame(close::status::value code,
|
||||
} else if (!ack) {
|
||||
m_alog.write(log::alevel::devel,"closing with no status code");
|
||||
m_local_close_code = close::status::no_status;
|
||||
m_local_close_reason = "";
|
||||
m_local_close_reason.clear();
|
||||
} else if (m_remote_close_code == close::status::no_status) {
|
||||
m_alog.write(log::alevel::devel,
|
||||
"acknowledging a no-status close with normal code");
|
||||
m_local_close_code = close::status::normal;
|
||||
m_local_close_reason = "";
|
||||
m_local_close_reason.clear();
|
||||
} else {
|
||||
m_alog.write(log::alevel::devel,"acknowledging with remote codes");
|
||||
m_local_close_code = m_remote_close_code;
|
||||
@@ -2269,7 +2269,7 @@ void connection<config>::log_open_result()
|
||||
|
||||
// User Agent
|
||||
std::string ua = m_request.get_header("User-Agent");
|
||||
if (ua == "") {
|
||||
if (ua.empty()) {
|
||||
s << "\"\" ";
|
||||
} else {
|
||||
// check if there are any quotes in the user agent
|
||||
@@ -2292,9 +2292,9 @@ void connection<config>::log_close_result()
|
||||
|
||||
s << "Disconnect "
|
||||
<< "close local:[" << m_local_close_code
|
||||
<< (m_local_close_reason == "" ? "" : ","+m_local_close_reason)
|
||||
<< (m_local_close_reason.empty() ? "" : ","+m_local_close_reason)
|
||||
<< "] remote:[" << m_remote_close_code
|
||||
<< (m_remote_close_reason == "" ? "" : ","+m_remote_close_reason) << "]";
|
||||
<< (m_remote_close_reason.empty() ? "" : ","+m_remote_close_reason) << "]";
|
||||
|
||||
m_alog.write(log::alevel::disconnect,s.str());
|
||||
}
|
||||
@@ -2319,7 +2319,7 @@ void connection<config>::log_fail_result()
|
||||
|
||||
// User Agent
|
||||
std::string ua = m_request.get_header("User-Agent");
|
||||
if (ua == "") {
|
||||
if (ua.empty()) {
|
||||
s << " \"\" ";
|
||||
} else {
|
||||
// check if there are any quotes in the user agent
|
||||
@@ -2348,7 +2348,7 @@ void connection<config>::log_http_result() {
|
||||
}
|
||||
|
||||
// Connection Type
|
||||
s << (m_request.get_header("host") == "" ? "-" : m_request.get_header("host"))
|
||||
s << (m_request.get_header("host").empty() ? "-" : m_request.get_header("host"))
|
||||
<< " " << transport_con_type::get_remote_endpoint()
|
||||
<< " \"" << m_request.get_method()
|
||||
<< " " << (m_uri ? m_uri->get_resource() : "-")
|
||||
@@ -2357,7 +2357,7 @@ void connection<config>::log_http_result() {
|
||||
|
||||
// User Agent
|
||||
std::string ua = m_request.get_header("User-Agent");
|
||||
if (ua == "") {
|
||||
if (ua.empty()) {
|
||||
s << " \"\" ";
|
||||
} else {
|
||||
// check if there are any quotes in the user agent
|
||||
|
||||
@@ -85,9 +85,9 @@ public:
|
||||
// Host is required by HTTP/1.1
|
||||
// Connection is required by is_websocket_handshake
|
||||
// Upgrade is required by is_websocket_handshake
|
||||
if (r.get_header("Sec-WebSocket-Key1") == "" ||
|
||||
r.get_header("Sec-WebSocket-Key2") == "" ||
|
||||
r.get_header("Sec-WebSocket-Key3") == "")
|
||||
if (r.get_header("Sec-WebSocket-Key1").empty() ||
|
||||
r.get_header("Sec-WebSocket-Key2").empty() ||
|
||||
r.get_header("Sec-WebSocket-Key3").empty())
|
||||
{
|
||||
return make_error_code(error::missing_required_header);
|
||||
}
|
||||
@@ -126,18 +126,18 @@ public:
|
||||
|
||||
// Echo back client's origin unless our local application set a
|
||||
// more restrictive one.
|
||||
if (res.get_header("Sec-WebSocket-Origin") == "") {
|
||||
if (res.get_header("Sec-WebSocket-Origin").empty()) {
|
||||
res.append_header("Sec-WebSocket-Origin",req.get_header("Origin"));
|
||||
}
|
||||
|
||||
// Echo back the client's request host unless our local application
|
||||
// set a different one.
|
||||
if (res.get_header("Sec-WebSocket-Location") == "") {
|
||||
if (res.get_header("Sec-WebSocket-Location").empty()) {
|
||||
uri_ptr uri = get_uri(req);
|
||||
res.append_header("Sec-WebSocket-Location",uri->str());
|
||||
}
|
||||
|
||||
if (subprotocol != "") {
|
||||
if (!subprotocol.empty()) {
|
||||
res.replace_header("Sec-WebSocket-Protocol",subprotocol);
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public:
|
||||
private:
|
||||
void decode_client_key(std::string const & key, char * result) const {
|
||||
unsigned int spaces = 0;
|
||||
std::string digits = "";
|
||||
std::string digits;
|
||||
uint32_t num;
|
||||
|
||||
// key2
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
// Host is required by HTTP/1.1
|
||||
// Connection is required by is_websocket_handshake
|
||||
// Upgrade is required by is_websocket_handshake
|
||||
if (r.get_header("Sec-WebSocket-Key") == "") {
|
||||
if (r.get_header("Sec-WebSocket-Key").empty()) {
|
||||
return make_error_code(error::missing_required_header);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ int get_websocket_version(request_type& r) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (r.get_header("Sec-WebSocket-Version") == "") {
|
||||
if (r.get_header("Sec-WebSocket-Version").empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
|
||||
// parse port
|
||||
std::string port = "";
|
||||
std::string port;
|
||||
while (state == 1) {
|
||||
if (it == uri_string.end()) {
|
||||
// state is not used after this point presently.
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
std::string const & resource)
|
||||
: m_scheme(secure ? "wss" : "ws")
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_port(port)
|
||||
, m_secure(secure)
|
||||
, m_valid(true) {}
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
uri(bool secure, std::string const & host, std::string const & resource)
|
||||
: m_scheme(secure ? "wss" : "ws")
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_port(secure ? uri_default_secure_port : uri_default_port)
|
||||
, m_secure(secure)
|
||||
, m_valid(true) {}
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
std::string const & resource)
|
||||
: m_scheme(secure ? "wss" : "ws")
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_secure(secure)
|
||||
{
|
||||
lib::error_code ec;
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
std::string const & resource)
|
||||
: m_scheme(scheme)
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_port(port)
|
||||
, m_secure(scheme == "wss" || scheme == "https")
|
||||
, m_valid(true) {}
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
uri(std::string scheme, std::string const & host, std::string const & resource)
|
||||
: m_scheme(scheme)
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_port((scheme == "wss" || scheme == "https") ? uri_default_secure_port : uri_default_port)
|
||||
, m_secure(scheme == "wss" || scheme == "https")
|
||||
, m_valid(true) {}
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
std::string const & port, std::string const & resource)
|
||||
: m_scheme(scheme)
|
||||
, m_host(host)
|
||||
, m_resource(resource == "" ? "/" : resource)
|
||||
, m_resource(resource.empty() ? "/" : resource)
|
||||
, m_secure(scheme == "wss" || scheme == "https")
|
||||
{
|
||||
lib::error_code ec;
|
||||
@@ -321,7 +321,7 @@ private:
|
||||
{
|
||||
ec = lib::error_code();
|
||||
|
||||
if (port == "") {
|
||||
if (port.empty()) {
|
||||
return (m_secure ? uri_default_secure_port : uri_default_port);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user