28#define BOOST_TEST_MODULE hybi_08_processor
29#include <boost/test/unit_test.hpp>
61 struct permessage_deflate_config {
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: 8\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\r\n";
79 r.consume(handshake.c_str(),handshake.size());
83 ec =
p.validate_handshake(
r);
90 BOOST_CHECK(u->get_valid() ==
true);
91 BOOST_CHECK(u->get_secure() ==
false);
92 BOOST_CHECK(u->get_host() ==
"www.example.com");
93 BOOST_CHECK(u->get_resource() ==
"/");
94 BOOST_CHECK(u->get_port() == websocketpp::uri_default_port);
96 p.process_handshake(
r,
"",response);
98 BOOST_CHECK(response.get_header(
"Connection") ==
"upgrade");
99 BOOST_CHECK(response.get_header(
"Upgrade") ==
"websocket");
100 BOOST_CHECK(response.get_header(
"Sec-WebSocket-Accept") ==
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
107 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: 8\r\nSec-WebSocket-Key: foo\r\n\r\n";
113 r.consume(handshake.c_str(),handshake.size());
117 ec =
p.validate_handshake(
r);
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: 8\r\nSec-WebSocket-Key: foo\r\n\r\n";
131 r.consume(handshake.c_str(),handshake.size());
135 ec =
p.validate_handshake(
r);
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: 8\r\n\r\n";
149 r.consume(handshake.c_str(),handshake.size());
153 ec =
p.validate_handshake(
r);
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: 8\r\n\r\n";
167 r.consume(handshake.c_str(),handshake.size());
171 ec =
p.validate_handshake(
r);
178 stub_config::con_msg_manager_type::ptr msg_manager;
182 websocketpp::lib::error_code ec;
184 std::string handshake =
"GET / HTTP/1.1\r\nHost: www.example.com:70000\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 8\r\nSec-WebSocket-Key: foo\r\n\r\n";
186 r.consume(handshake.c_str(),handshake.size());
190 ec =
p.validate_handshake(
r);
195 BOOST_CHECK( !u->get_valid() );
Stub class for use when disabling permessage_deflate extension.
Stores, parses, and manipulates HTTP requests.
Stores, parses, and manipulates HTTP responses.
Represents a buffer for a single WebSocket message.
Processor for Hybi Draft version 08.
Thread safe stub "random" integer generator.
BOOST_AUTO_TEST_CASE(exact_match)
@ missing_required_header
Missing Required Header.
@ invalid_http_method
Invalid HTTP method.
@ invalid_http_version
Invalid HTTP version.
int get_websocket_version(request_type &r)
Extract the version from a WebSocket handshake request.
bool is_websocket_handshake(request_type &r)
Determine whether or not a generic HTTP request is a WebSocket handshake.
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
stub_config::request_type request_type
static const bool enable_extensions
Extension related config.
websocketpp::extensions::permessage_deflate::disabled< permessage_deflate_config > permessage_deflate_type
core::message_type message_type
core::con_msg_manager_type con_msg_manager_type
core::request_type request_type
static const size_t max_message_size
core::response_type response_type