28 #define BOOST_TEST_MODULE hybi_07_processor 29 #include <boost/test/unit_test.hpp> 72 stub_config::con_msg_manager_type::ptr msg_manager;
75 websocketpp::lib::error_code ec;
77 std::string handshake =
"GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\r\n";
79 r.consume(handshake.c_str(),handshake.size());
90 BOOST_CHECK(u->get_valid());
91 BOOST_CHECK(!u->get_secure());
92 BOOST_CHECK_EQUAL(u->get_host(),
"www.example.com");
93 BOOST_CHECK_EQUAL(u->get_resource(),
"/");
98 BOOST_CHECK_EQUAL(response.get_header(
"Connection"),
"upgrade");
99 BOOST_CHECK_EQUAL(response.get_header(
"Upgrade"),
"websocket");
100 BOOST_CHECK_EQUAL(response.get_header(
"Sec-WebSocket-Accept"),
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
106 stub_config::con_msg_manager_type::ptr msg_manager;
109 websocketpp::lib::error_code ec;
111 std::string handshake =
"POST / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\nSec-WebSocket-Key: foo\r\n\r\n";
113 r.consume(handshake.c_str(),handshake.size());
124 stub_config::con_msg_manager_type::ptr msg_manager;
127 websocketpp::lib::error_code ec;
129 std::string handshake =
"GET / HTTP/1.0\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\nSec-WebSocket-Key: foo\r\n\r\n";
131 r.consume(handshake.c_str(),handshake.size());
142 stub_config::con_msg_manager_type::ptr msg_manager;
145 websocketpp::lib::error_code ec;
147 std::string handshake =
"GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\n\r\n";
149 r.consume(handshake.c_str(),handshake.size());
160 stub_config::con_msg_manager_type::ptr msg_manager;
163 websocketpp::lib::error_code ec;
165 std::string handshake =
"GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\n\r\n";
167 r.consume(handshake.c_str(),handshake.size());
178 stub_config::con_msg_manager_type::ptr msg_manager;
181 websocketpp::lib::error_code ec;
183 std::string handshake =
"GET / HTTP/1.1\r\nHost: www.example.com:70000\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 7\r\nSec-WebSocket-Key: foo\r\n\r\n";
185 r.consume(handshake.c_str(),handshake.size());
192 BOOST_CHECK( !p.
get_uri(r)->get_valid() );
bool is_websocket_handshake(request_type &r)
Determine whether or not a generic HTTP request is a WebSocket handshake.
lib::error_code validate_handshake(request_type const &r) const
validate a WebSocket handshake request for this version
int get_websocket_version(request_type &r)
Extract the version from a WebSocket handshake request.
lib::error_code process_handshake(request_type const &request, std::string const &subprotocol, response_type &response) const
Calculate the appropriate response for this websocket request.
websocketpp::extensions::permessage_deflate::disabled< permessage_deflate_config > permessage_deflate_type
websocketpp::random::none::int_generator< uint32_t > rng_type
Stores, parses, and manipulates HTTP responses.
Stub class for use when disabling permessage_deflate extension.
websocketpp::http::parser::response response_type
Processor for Hybi Draft version 07.
int get_version() const
Get the protocol version of this processor.
Thread safe stub "random" integer generator.
Represents a buffer for a single WebSocket message.
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
stub_config::request_type request_type
websocketpp::http::parser::request request_type
BOOST_AUTO_TEST_CASE(exact_match)
core::request_type request_type
Extension specific config.
static const size_t max_message_size
Stores, parses, and manipulates HTTP requests.
core::response_type response_type
websocketpp::message_buffer::alloc::con_msg_manager< message_type > con_msg_manager_type
static const bool enable_extensions
Extension related config.
static uint16_t const uri_default_port
Default port for ws://.
A connection message manager that allocates a new message for each request.
uri_ptr get_uri(request_type const &request) const
Extracts client uri from a handshake request.
websocketpp::message_buffer::message< websocketpp::message_buffer::alloc::con_msg_manager > message_type