Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zaphoyd/websocketpp into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
Peter Thorson committed Feb 21, 2016
2 parents fabf8bf + d3bec51 commit a495c8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
20 changes: 17 additions & 3 deletions websocketpp/processors/hybi00.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,29 @@ class hybi00 : public processor<config> {

/// Extracts requested subprotocols from a handshake request
/**
* hybi00 doesn't support subprotocols so there never will be any requested
* hybi00 does support subprotocols
* https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-1.9
*
* @param [in] req The request to extract from
* @param [out] subprotocol_list A reference to a vector of strings to store
* the results in.
*/
lib::error_code extract_subprotocols(request_type const &,
std::vector<std::string> &)
lib::error_code extract_subprotocols(request_type const & req,
std::vector<std::string> & subprotocol_list)
{
if (!req.get_header("Sec-WebSocket-Protocol").empty()) {
http::parameter_list p;

if (!req.get_header_as_plist("Sec-WebSocket-Protocol",p)) {
http::parameter_list::const_iterator it;

for (it = p.begin(); it != p.end(); ++it) {
subprotocol_list.push_back(it->first);
}
} else {
return error::make_error_code(error::subprotocol_parse_error);
}
}
return lib::error_code();
}

Expand Down
9 changes: 5 additions & 4 deletions websocketpp/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,21 @@ class uri {
int state = 0;

it = uri_string.begin();
size_t uri_len = uri_string.length();

if (std::equal(it,it+6,"wss://")) {
if (uri_len >= 7 && std::equal(it,it+6,"wss://")) {
m_secure = true;
m_scheme = "wss";
it += 6;
} else if (std::equal(it,it+5,"ws://")) {
} else if (uri_len >= 6 && std::equal(it,it+5,"ws://")) {
m_secure = false;
m_scheme = "ws";
it += 5;
} else if (std::equal(it,it+7,"http://")) {
} else if (uri_len >= 8 && std::equal(it,it+7,"http://")) {
m_secure = false;
m_scheme = "http";
it += 7;
} else if (std::equal(it,it+8,"https://")) {
} else if (uri_len >= 9 && std::equal(it,it+8,"https://")) {
m_secure = true;
m_scheme = "https";
it += 8;
Expand Down

0 comments on commit a495c8c

Please sign in to comment.