Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
hybi07.cpp File Reference
Include dependency graph for hybi07.cpp:

Go to the source code of this file.

Classes

struct  stub_config
 
struct  stub_config::permessage_deflate_config
 Extension specific config. More...
 

Macros

#define BOOST_TEST_MODULE   hybi_07_processor
 

Functions

 BOOST_AUTO_TEST_CASE (exact_match)
 
 BOOST_AUTO_TEST_CASE (non_get_method)
 
 BOOST_AUTO_TEST_CASE (old_http_version)
 
 BOOST_AUTO_TEST_CASE (missing_handshake_key1)
 
 BOOST_AUTO_TEST_CASE (missing_handshake_key2)
 
 BOOST_AUTO_TEST_CASE (bad_host)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   hybi_07_processor

Definition at line 28 of file hybi07.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( bad_host )

Definition at line 175 of file hybi07.cpp.

175 {
178 stub_config::con_msg_manager_type::ptr msg_manager;
180 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
181 websocketpp::lib::error_code ec;
182
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";
184
185 r.consume(handshake.c_str(),handshake.size());
186
188 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
189 ec = p.validate_handshake(r);
190 BOOST_CHECK( !ec );
191
192 BOOST_CHECK( !p.get_uri(r)->get_valid() );
193}
const mie::Vuint & p
Definition bn.cpp:27
const mie::Vuint & r
Definition bn.cpp:28
Processor for Hybi Draft version 07.
Definition hybi07.hpp:44
std::mt19937 & rng()
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.
Definition processor.hpp:68
core::rng_type rng_type
core::request_type request_type
core::response_type response_type
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/6]

BOOST_AUTO_TEST_CASE ( exact_match )

Definition at line 69 of file hybi07.cpp.

69 {
72 stub_config::con_msg_manager_type::ptr msg_manager;
74 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
75 websocketpp::lib::error_code ec;
76
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";
78
79 r.consume(handshake.c_str(),handshake.size());
80
82 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
83 ec = p.validate_handshake(r);
84 BOOST_CHECK(!ec);
85
87
88 u = p.get_uri(r);
89
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(), "/");
94 BOOST_CHECK_EQUAL(u->get_port(), websocketpp::uri_default_port);
95
96 p.process_handshake(r,"",response);
97
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=");
101}
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
Definition uri.hpp:351
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( missing_handshake_key1 )

Definition at line 139 of file hybi07.cpp.

139 {
142 stub_config::con_msg_manager_type::ptr msg_manager;
144 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
145 websocketpp::lib::error_code ec;
146
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";
148
149 r.consume(handshake.c_str(),handshake.size());
150
152 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
153 ec = p.validate_handshake(r);
155}
@ missing_required_header
Missing Required Header.
Definition base.hpp:129
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( missing_handshake_key2 )

Definition at line 157 of file hybi07.cpp.

157 {
160 stub_config::con_msg_manager_type::ptr msg_manager;
162 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
163 websocketpp::lib::error_code ec;
164
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";
166
167 r.consume(handshake.c_str(),handshake.size());
168
170 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
171 ec = p.validate_handshake(r);
173}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( non_get_method )

Definition at line 103 of file hybi07.cpp.

103 {
106 stub_config::con_msg_manager_type::ptr msg_manager;
108 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
109 websocketpp::lib::error_code ec;
110
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";
112
113 r.consume(handshake.c_str(),handshake.size());
114
116 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
117 ec = p.validate_handshake(r);
119}
@ invalid_http_method
Invalid HTTP method.
Definition base.hpp:120
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( old_http_version )

Definition at line 121 of file hybi07.cpp.

121 {
124 stub_config::con_msg_manager_type::ptr msg_manager;
126 websocketpp::processor::hybi07<stub_config> p(false,true,msg_manager,rng);
127 websocketpp::lib::error_code ec;
128
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";
130
131 r.consume(handshake.c_str(),handshake.size());
132
134 BOOST_CHECK(websocketpp::processor::get_websocket_version(r) == p.get_version());
135 ec = p.validate_handshake(r);
137}
@ invalid_http_version
Invalid HTTP version.
Definition base.hpp:123
Here is the call graph for this function: