mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
updates processors to support writing handshake requests with subprotocols
This commit is contained in:
@@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE( client_handshake_request ) {
|
||||
|
||||
websocketpp::uri_ptr u(new websocketpp::uri("ws://localhost/"));
|
||||
|
||||
env.p.client_handshake_request(env.req,u);
|
||||
env.p.client_handshake_request(env.req,u, std::vector<std::string>());
|
||||
|
||||
BOOST_CHECK_EQUAL( env.req.get_method(), "GET" );
|
||||
BOOST_CHECK_EQUAL( env.req.get_version(), "HTTP/1.1");
|
||||
|
||||
@@ -1080,14 +1080,14 @@ template <typename config>
|
||||
void connection<config>::send_http_request() {
|
||||
m_alog.write(log::alevel::devel,"connection send_http_request");
|
||||
|
||||
// TODO: origin header
|
||||
// TODO: subprotocol requests
|
||||
// TODO: origin header?
|
||||
|
||||
// Have the protocol processor fill in the appropriate fields based on the
|
||||
// selected client version
|
||||
if (m_processor) {
|
||||
lib::error_code ec;
|
||||
ec = m_processor->client_handshake_request(m_request,m_uri);
|
||||
ec = m_processor->client_handshake_request(m_request,m_uri,
|
||||
m_requested_subprotocols);
|
||||
|
||||
if (ec) {
|
||||
m_elog.write(log::elevel::fatal,
|
||||
|
||||
@@ -137,8 +137,8 @@ public:
|
||||
}
|
||||
|
||||
// outgoing client connection processing is not supported for this version
|
||||
lib::error_code client_handshake_request(request_type& req, uri_ptr uri)
|
||||
const
|
||||
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
|
||||
const std::vector<std::string> & subprotocols) const
|
||||
{
|
||||
return error::make_error_code(error::no_protocol_support);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace processor {
|
||||
template <typename config>
|
||||
class hybi07 : public hybi08<config> {
|
||||
public:
|
||||
typedef typename config::request_type request_type;
|
||||
|
||||
typedef typename config::con_msg_manager_type::ptr msg_manager_ptr;
|
||||
typedef typename config::rng_type rng_type;
|
||||
|
||||
@@ -47,6 +49,13 @@ public:
|
||||
rng_type& rng)
|
||||
: hybi08<config>(secure, server, manager, rng) {}
|
||||
|
||||
// outgoing client connection processing is not supported for this version
|
||||
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
|
||||
const std::vector<std::string> & subprotocols) const
|
||||
{
|
||||
return error::make_error_code(error::no_protocol_support);
|
||||
}
|
||||
|
||||
int get_version() const {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,13 @@ public:
|
||||
rng_type& rng)
|
||||
: hybi13<config>(secure, server, manager, rng) {}
|
||||
|
||||
// outgoing client connection processing is not supported for this version
|
||||
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
|
||||
const std::vector<std::string> & subprotocols) const
|
||||
{
|
||||
return error::make_error_code(error::no_protocol_support);
|
||||
}
|
||||
|
||||
int get_version() const {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
}
|
||||
|
||||
lib::error_code client_handshake_request(request_type& req, uri_ptr
|
||||
uri) const
|
||||
uri, const std::vector<std::string> & subprotocols) const
|
||||
{
|
||||
req.set_method("GET");
|
||||
req.set_uri(uri->get_resource());
|
||||
@@ -203,6 +203,17 @@ public:
|
||||
req.replace_header("Sec-WebSocket-Version","13");
|
||||
req.replace_header("Host",uri->get_host_port());
|
||||
|
||||
if (!subprotocols.empty()) {
|
||||
std::ostringstream result;
|
||||
std::vector<std::string>::const_iterator it = subprotocols.begin();
|
||||
result << *it++;
|
||||
while (it != subprotocols.end()) {
|
||||
result << ", " << *it++;
|
||||
}
|
||||
|
||||
req.replace_header("Sec-WebSocket-Protocol",result.str());
|
||||
}
|
||||
|
||||
// Generate handshake key
|
||||
frame::uint32_converter conv;
|
||||
unsigned char raw_key[16];
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
* @return An error code, 0 on success, non-zero for other errors
|
||||
*/
|
||||
virtual lib::error_code client_handshake_request(request_type& req,
|
||||
uri_ptr uri) const = 0;
|
||||
uri_ptr uri, const std::vector<std::string> & subprotocols) const = 0;
|
||||
|
||||
/// Validate the server's response to an outgoing handshake request
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user