mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
adds subprotocol processing to handshake processors
This commit is contained in:
@@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE( exact_match ) {
|
||||
BOOST_CHECK(u->get_resource() == "/");
|
||||
BOOST_CHECK(u->get_port() == websocketpp::URI_DEFAULT_PORT);
|
||||
|
||||
p.process_handshake(r,response);
|
||||
p.process_handshake(r,"",response);
|
||||
|
||||
BOOST_CHECK(response.get_header("Connection") == "Upgrade");
|
||||
BOOST_CHECK(response.get_header("Upgrade") == "websocket");
|
||||
|
||||
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE( exact_match ) {
|
||||
BOOST_CHECK(u->get_resource() == "/");
|
||||
BOOST_CHECK(u->get_port() == websocketpp::uri_default_port);
|
||||
|
||||
p.process_handshake(r,response);
|
||||
p.process_handshake(r,"",response);
|
||||
|
||||
BOOST_CHECK(response.get_header("Connection") == "upgrade");
|
||||
BOOST_CHECK(response.get_header("Upgrade") == "websocket");
|
||||
|
||||
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE( exact_match ) {
|
||||
BOOST_CHECK(u->get_resource() == "/");
|
||||
BOOST_CHECK(u->get_port() == websocketpp::uri_default_port);
|
||||
|
||||
p.process_handshake(r,response);
|
||||
p.process_handshake(r,"",response);
|
||||
|
||||
BOOST_CHECK(response.get_header("Connection") == "upgrade");
|
||||
BOOST_CHECK(response.get_header("Upgrade") == "websocket");
|
||||
|
||||
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE( exact_match ) {
|
||||
BOOST_CHECK_EQUAL(u->get_resource(), "/");
|
||||
BOOST_CHECK_EQUAL(u->get_port(), websocketpp::uri_default_port);
|
||||
|
||||
env.p.process_handshake(env.req,env.res);
|
||||
env.p.process_handshake(env.req,"",env.res);
|
||||
|
||||
BOOST_CHECK_EQUAL(env.res.get_header("Connection"), "upgrade");
|
||||
BOOST_CHECK_EQUAL(env.res.get_header("Upgrade"), "websocket");
|
||||
|
||||
@@ -91,8 +91,8 @@ public:
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
lib::error_code process_handshake(const request_type& req,
|
||||
response_type& res) const
|
||||
lib::error_code process_handshake(const request_type& req, const
|
||||
std::string & subprotocol, response_type& res) const
|
||||
{
|
||||
char key_final[16];
|
||||
|
||||
|
||||
@@ -165,8 +165,12 @@ public:
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
lib::error_code process_handshake(const request_type& request,
|
||||
response_type& response) const
|
||||
/* TODO: the 'subprotocol' parameter may need to be expanded into a more
|
||||
* generic struct if other user input parameters to the processed handshake
|
||||
* are found.
|
||||
*/
|
||||
lib::error_code process_handshake(const request_type& request, const
|
||||
std::string & subprotocol, response_type& response) const
|
||||
{
|
||||
std::string server_key = request.get_header("Sec-WebSocket-Key");
|
||||
|
||||
@@ -180,6 +184,10 @@ public:
|
||||
response.append_header("Upgrade",constants::upgrade_token);
|
||||
response.append_header("Connection",constants::connection_token);
|
||||
|
||||
if (!subprotocol.empty()) {
|
||||
response.replace_header("Sec-WebSocket-Protocol",subprotocol);
|
||||
}
|
||||
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,9 +128,7 @@ int get_websocket_version(request_type& r) {
|
||||
//
|
||||
// // handle msg;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
template <typename config>
|
||||
class processor {
|
||||
@@ -186,12 +184,14 @@ public:
|
||||
/**
|
||||
* @param req The request to process
|
||||
*
|
||||
* @param subprotocol The subprotocol in use
|
||||
*
|
||||
* @param res The response to store the processed response in
|
||||
*
|
||||
* @return An error code, 0 on success, non-zero for other errors
|
||||
*/
|
||||
virtual lib::error_code process_handshake(const request_type& req,
|
||||
response_type& res) const = 0;
|
||||
virtual lib::error_code process_handshake(const request_type& req, const
|
||||
std::string & subprotocol, response_type& res) const = 0;
|
||||
|
||||
/// Fill in an HTTP request for an outgoing connection handshake
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user