NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
connection.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Peter Thorson. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the name of the WebSocket++ Project nor the
12  * names of its contributors may be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  */
27 //#define BOOST_TEST_DYN_LINK
28 #define BOOST_TEST_MODULE connection
29 #include <boost/test/unit_test.hpp>
30 
31 #include "connection_tu2.hpp"
32 
33 // Include special debugging transport
34 //#include <websocketpp/config/minimal_client.hpp>
36 
37 // NOTE: these tests currently test against hardcoded output values. I am not
38 // sure how problematic this will be. If issues arise like order of headers the
39 // output should be parsed by http::response and have values checked directly
40 
41 BOOST_AUTO_TEST_CASE( basic_http_request ) {
42  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
43  std::string output = "HTTP/1.1 426 Upgrade Required\r\nServer: " +
44  std::string(websocketpp::user_agent)+"\r\n\r\n";
45 
46  std::string o2 = run_server_test(input);
47 
48  BOOST_CHECK(o2 == output);
49 }
50 
53 
55  return extension_value;
56  }
57 
58  bool is_server() const {
59  return false;
60  }
61 
63 };
64 
66  typedef core::concurrency_type concurrency_type;
67 
68  typedef core::request_type request_type;
69  typedef core::response_type response_type;
70 
71  typedef core::message_type message_type;
73  typedef core::endpoint_msg_manager_type endpoint_msg_manager_type;
74 
75  typedef core::alog_type alog_type;
76  typedef core::elog_type elog_type;
77 
78  typedef core::rng_type rng_type;
79 
80  typedef core::transport_type transport_type;
81 
82  typedef core::endpoint_base endpoint_base;
84 };
85 
88 
89  typedef core::concurrency_type concurrency_type;
90 
91  typedef core::request_type request_type;
92  typedef core::response_type response_type;
93 
94  typedef core::message_type message_type;
96  typedef core::endpoint_msg_manager_type endpoint_msg_manager_type;
97 
98  typedef core::alog_type alog_type;
99  typedef core::elog_type elog_type;
100 
102 
109 
113  static bool const enable_multithreading = true;
114 
116  static const long timeout_socket_pre_init = 5000;
117  static const long timeout_proxy = 5000;
118  static const long timeout_socket_post_init = 5000;
119  static const long timeout_connect = 5000;
120  static const long timeout_socket_shutdown = 5000;
121  };
122 
126 
127  typedef core::endpoint_base endpoint_base;
129 
132 };
133 
135  connection_setup(bool p_is_server)
136  : alog(websocketpp::lib::make_shared<stub_config::alog_type>())
137  , elog(websocketpp::lib::make_shared<stub_config::elog_type>())
138  , c(p_is_server, "", alog, elog, rng) {}
139 
140  websocketpp::lib::error_code ec;
141  websocketpp::lib::shared_ptr<stub_config::alog_type> alog;
142  websocketpp::lib::shared_ptr<stub_config::elog_type> elog;
145 };
146 
149 
150 /*void echo_func(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
151  s->send(hdl, msg->get_payload(), msg->get_opcode());
152 }*/
153 
155  s->send(hdl, msg->get_payload(), msg->get_opcode());
156 }
157 
160  con->replace_header("Server","foo");
161  return true;
162 }
163 
165  using namespace websocketpp::http;
166 
168 
169  std::string res = con->get_resource();
170 
171  con->set_body(res);
172  con->set_status(status_code::ok);
173 
174  BOOST_CHECK_EQUAL(con->get_response_code(), status_code::ok);
175  BOOST_CHECK_EQUAL(con->get_response_msg(), status_code::get_string(status_code::ok));
176 }
177 
179  *deferred = true;
180 
182 
183  websocketpp::lib::error_code ec = con->defer_http_response();
184  BOOST_CHECK_EQUAL(ec, websocketpp::lib::error_code());
185 }
186 
187 void check_on_fail(server* s, websocketpp::lib::error_code ec, bool & called,
189 {
191 
192  BOOST_CHECK_EQUAL(ec, con->get_ec());
193  called = true;
194 }
195 
197 {
199 
200  std::cout << con->get_uri() << std::endl;
201 }
202 
204  BOOST_CHECK(false);
205 }
207  BOOST_CHECK(false);
208 }
209 
210 BOOST_AUTO_TEST_CASE( connection_extensions ) {
211  connection_setup env(true);
212 
213  BOOST_CHECK( env.c.extension_value == 5 );
214  BOOST_CHECK( env.c.extension_method() == 5 );
215 
216  BOOST_CHECK( env.c.is_server() == true );
217 }
218 
219 BOOST_AUTO_TEST_CASE( basic_websocket_request ) {
220  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
221  std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nServer: ";
222  output+=websocketpp::user_agent;
223  output+="\r\nUpgrade: websocket\r\n\r\n";
224 
225  server s;
226  s.set_message_handler(bind(&echo_func,&s,::_1,::_2));
227 
228  BOOST_CHECK(run_server_test(s,input) == output);
229 }
230 
231 BOOST_AUTO_TEST_CASE( http_request ) {
232  std::string input = "GET /foo/bar HTTP/1.1\r\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
233  std::string output = "HTTP/1.1 200 OK\r\nContent-Length: 8\r\nServer: ";
234  output+=websocketpp::user_agent;
235  output+="\r\n\r\n/foo/bar";
236 
237  server s;
238  s.set_http_handler(bind(&http_func,&s,::_1));
239 
240  BOOST_CHECK_EQUAL(run_server_test(s,input), output);
241 }
242 
243 BOOST_AUTO_TEST_CASE( deferred_http_request ) {
244  std::string input = "GET /foo/bar HTTP/1.1\r\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
245  std::string output = "HTTP/1.1 200 OK\r\nContent-Length: 8\r\nServer: ";
246  output+=websocketpp::user_agent;
247  output+="\r\n\r\n/foo/bar";
248 
249  server s;
251  bool deferred = false;
252  s.set_http_handler(bind(&defer_http_func,&s, &deferred,::_1));
253 
256 
257  std::stringstream ostream;
258  s.register_ostream(&ostream);
259 
260  con = s.get_connection();
261  con->start();
262 
263  BOOST_CHECK(!deferred);
264  BOOST_CHECK_EQUAL(ostream.str(), "");
265  con->read_some(input.data(),input.size());
266  BOOST_CHECK(deferred);
267  BOOST_CHECK_EQUAL(ostream.str(), "");
268 
269  con->set_body(con->get_resource());
270  con->set_status(websocketpp::http::status_code::ok);
271 
272  websocketpp::lib::error_code ec;
273  s.send_http_response(con->get_handle(),ec);
274  BOOST_CHECK_EQUAL(ec, websocketpp::lib::error_code());
275  BOOST_CHECK_EQUAL(ostream.str(), output);
276  con->send_http_response(ec);
277  BOOST_CHECK_EQUAL(ec, make_error_code(websocketpp::error::invalid_state));
278 
279 }
280 
281 BOOST_AUTO_TEST_CASE( request_no_server_header ) {
282  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
283  std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nUpgrade: websocket\r\n\r\n";
284 
285  server s;
286  s.set_user_agent("");
287  s.set_message_handler(bind(&echo_func,&s,::_1,::_2));
288 
289  BOOST_CHECK_EQUAL(run_server_test(s,input), output);
290 }
291 
292 BOOST_AUTO_TEST_CASE( request_no_server_header_override ) {
293  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
294  std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nServer: foo\r\nUpgrade: websocket\r\n\r\n";
295 
296  server s;
297  s.set_user_agent("");
298  s.set_message_handler(bind(&echo_func,&s,::_1,::_2));
299  s.set_validate_handler(bind(&validate_set_ua,&s,::_1));
300 
301  BOOST_CHECK_EQUAL(run_server_test(s,input), output);
302 }
303 
304 BOOST_AUTO_TEST_CASE( basic_client_websocket ) {
305  std::string uri = "ws://localhost";
306 
307  //std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nServer: foo\r\nUpgrade: websocket\r\n\r\n";
308 
309  std::string ref = "GET / HTTP/1.1\r\nConnection: Upgrade\r\nFoo: Bar\r\nHost: localhost\r\nSec-WebSocket-Key: AAAAAAAAAAAAAAAAAAAAAA==\r\nSec-WebSocket-Version: 13\r\nUpgrade: websocket\r\nUser-Agent: foo\r\n\r\n";
310 
311  std::stringstream output;
312 
313  client e;
316  e.set_user_agent("foo");
317  e.register_ostream(&output);
318 
320  websocketpp::lib::error_code ec;
321  con = e.get_connection(uri, ec);
322  con->append_header("Foo","Bar");
323  e.connect(con);
324 
325  BOOST_CHECK_EQUAL(ref, output.str());
326 }
327 
328 BOOST_AUTO_TEST_CASE( set_max_message_size ) {
329  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\r\n";
330 
331  // After the handshake, add a single frame with a message that is too long.
332  char frame0[10] = {char(0x82), char(0x83), 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01};
333  input.append(frame0, 10);
334 
335  std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nServer: foo\r\nUpgrade: websocket\r\n\r\n";
336 
337  // After the handshake, add a single frame with a close message with message too big
338  // error code.
339  char frame1[4] = {char(0x88), 0x19, 0x03, char(0xf1)};
340  output.append(frame1, 4);
341  output.append("A message was too large");
342 
343  server s;
344  s.set_user_agent("");
345  s.set_validate_handler(bind(&validate_set_ua,&s,::_1));
347 
348  BOOST_CHECK_EQUAL(run_server_test(s,input), output);
349 }
350 
351 BOOST_AUTO_TEST_CASE( websocket_fail_parse_error ) {
352  std::string input = "asdf\r\n\r\n";
353 
354  server s;
355  websocketpp::lib::error_code ec = make_error_code(websocketpp::error::http_parse_error);
356  bool called = false;
357  s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
358 
359  run_server_test(s,input,false);
360  BOOST_CHECK(called);
361 }
362 
363 BOOST_AUTO_TEST_CASE( websocket_fail_invalid_version ) {
364  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: foo\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
365 
366  server s;
367  websocketpp::lib::error_code ec = make_error_code(websocketpp::error::invalid_version);
368  bool called = false;
369  s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
370 
371  run_server_test(s,input,false);
372  BOOST_CHECK(called);
373 }
374 
375 BOOST_AUTO_TEST_CASE( websocket_fail_unsupported_version ) {
376  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 12\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
377 
378  server s;
379  websocketpp::lib::error_code ec = make_error_code(websocketpp::error::unsupported_version);
380  bool called = false;
381  s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
382 
383  run_server_test(s,input,false);
384  BOOST_CHECK(called);
385 }
386 
387 // BOOST_AUTO_TEST_CASE( websocket_fail_invalid_uri ) {
388 // std::string input = "GET http://345.123.123.123/foo HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
389 
390 // server s;
391 // websocketpp::lib::error_code ec = make_error_code(websocketpp::error::unsupported_version);
392 // bool called = false;
393 // s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
394 // s.set_open_handler(bind(&on_open_print,&s,::_1));
395 
396 // std::cout << run_server_test(s,input,true) << std::endl;
397 // BOOST_CHECK(called);
398 // }
399 
400 // BOOST_AUTO_TEST_CASE( websocket_fail_invalid_uri_http ) {
401 // std::string input = "GET http://345.123.123.123/foo HTTP/1.1\r\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
402 
403 // server s;
404 // websocketpp::lib::error_code ec = make_error_code(websocketpp::error::unsupported_version);
405 // bool called = false;
406 // s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
407 // s.set_open_handler(bind(&on_open_print,&s,::_1));
408 
409 // std::cout << run_server_test(s,input,true) << std::endl;
410 // BOOST_CHECK(called);
411 // }
412 
413 BOOST_AUTO_TEST_CASE( websocket_fail_upgrade_required ) {
414  std::string input = "GET /foo/bar HTTP/1.1\r\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
415 
416  server s;
417  websocketpp::lib::error_code ec = make_error_code(websocketpp::error::upgrade_required);
418  bool called = false;
419  s.set_fail_handler(bind(&check_on_fail,&s,ec,websocketpp::lib::ref(called),::_1));
420 
421  run_server_test(s,input,false);
422  BOOST_CHECK(called);
423 }
424 
425 // TODO: set max message size in client endpoint test case
426 // TODO: set max message size mid connection test case
427 // TODO: [maybe] set max message size in open handler
428 
429 
430 
431 // BOOST_AUTO_TEST_CASE( user_reject_origin ) {
432 // std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example2.com\r\n\r\n";
433 // std::string output = "HTTP/1.1 403 Forbidden\r\nServer: "+websocketpp::USER_AGENT+"\r\n\r\n";
434 
435 // BOOST_CHECK(run_server_test(input) == output);
436 // }
437 
438 // BOOST_AUTO_TEST_CASE( basic_text_message ) {
439 // std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
440 
441 // unsigned char frames[8] = {0x82,0x82,0xFF,0xFF,0xFF,0xFF,0xD5,0xD5};
442 // input.append(reinterpret_cast<char*>(frames),8);
443 
444 // std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\nServer: "+websocketpp::USER_AGENT+"\r\nUpgrade: websocket\r\n\r\n**";
445 
446 // BOOST_CHECK( run_server_test(input) == output);
447 // }
448 
449 
450 
451 
452 
453 
454 BOOST_AUTO_TEST_CASE( client_handshake_timeout_race1 ) {
455  debug_client c;
456 
457  websocketpp::lib::error_code ec;
458  debug_client::connection_ptr con = c.get_connection("ws://localhost:9002", ec);
459 
460  BOOST_CHECK(!ec);
461 
462  // This test the case where a handshake times out immediately before the
463  // handler that would have completed it gets invoked. This situation happens
464  // when clients are connecting to overloaded servers and on servers that are
465  // overloaded.
466  c.connect(con);
467 
468  con->expire_timer(websocketpp::lib::error_code());
469  // Fullfil the write to simulate the write completing immediately after
470  // timer expires
471  con->fullfil_write();
472 
473  BOOST_CHECK_EQUAL(con->get_ec(), make_error_code(websocketpp::error::open_handshake_timeout));
474 }
475 
476 BOOST_AUTO_TEST_CASE( client_handshake_timeout_race2 ) {
477  debug_client c;
478 
479  websocketpp::lib::error_code ec;
480  debug_client::connection_ptr con = c.get_connection("ws://localhost:9002", ec);
481 
482  BOOST_CHECK(!ec);
483 
484  std::string output = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: ICX+Yqv66kxgM0FcWaLWlFLwTAI=\r\nServer: foo\r\nUpgrade: websocket\r\n\r\n";
485 
486  // This test the case where a handshake times out immediately before the
487  // handler that would have completed it gets invoked. This situation happens
488  // when clients are connecting to overloaded servers and on servers that are
489  // overloaded.
490  c.connect(con);
491  con->fullfil_write();
492 
493  con->expire_timer(websocketpp::lib::error_code());
494  // Read valid handshake to simulate receiving the handshake response
495  // immediately after the timer expires
496  con->read_all(output.data(),output.size());
497 
498  BOOST_CHECK_EQUAL(con->get_ec(), make_error_code(websocketpp::error::open_handshake_timeout));
499 }
500 
501 BOOST_AUTO_TEST_CASE( server_handshake_timeout_race1 ) {
502  debug_server s;
503 
504  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: AAAAAAAAAAAAAAAAAAAAAA==\r\n\r\n";
505 
507  con->start();
508 
509  con->expire_timer(websocketpp::lib::error_code());
510  // Read handshake immediately after timer expire
511  con->read_all(input.data(), input.size());
512 
513  BOOST_CHECK_EQUAL(con->get_ec(), make_error_code(websocketpp::error::open_handshake_timeout));
514 }
515 
516 BOOST_AUTO_TEST_CASE( server_handshake_timeout_race2 ) {
517  debug_server s;
518 
519  std::string input = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: AAAAAAAAAAAAAAAAAAAAAA==\r\n\r\n";
520 
522  con->start();
523 
524  con->read_all(input.data(), input.size());
525 
526  con->expire_timer(websocketpp::lib::error_code());
527  // Complete write immediately after timer expire
528  con->fullfil_write();
529 
530  BOOST_CHECK_EQUAL(con->get_ec(), make_error_code(websocketpp::error::open_handshake_timeout));
531 }
532 
533 
void send_http_response(connection_hdl hdl, lib::error_code &ec)
Send deferred HTTP Response.
static level const all
Special aggregate value representing "all levels".
Definition: levels.hpp:152
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
void fail_on_http(websocketpp::connection_hdl)
Definition: connection.cpp:206
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
static level const none
Special aggregate value representing "no levels".
Definition: levels.hpp:61
lib::error_code make_error_code(error::value e)
Definition: error.hpp:235
void fail_on_open(websocketpp::connection_hdl)
Definition: connection.cpp:203
connection_extension connection_base
Definition: connection.cpp:83
core::concurrency_type concurrency_type
Definition: connection.cpp:89
core::con_msg_manager_type con_msg_manager_type
Definition: connection.cpp:72
stub_config::rng_type rng
Definition: connection.cpp:143
std::string run_server_test(std::string input, bool log)
core::message_type message_type
Definition: connection.cpp:71
core::elog_type elog_type
Definition: connection.cpp:99
void http_func(server *s, websocketpp::connection_hdl hdl)
Definition: connection.cpp:164
core::rng_type rng_type
Definition: connection.cpp:78
core::endpoint_base endpoint_base
Definition: connection.cpp:82
core::transport_type transport_type
Definition: connection.cpp:80
type::concurrency_type concurrency_type
Definition: connection.cpp:104
void validate_func(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
Definition: connection.cpp:154
websocketpp::server< debug_config_client > debug_server
Definition: connection.cpp:148
Client endpoint role based on the given config.
core::request_type request_type
Definition: connection.cpp:91
websocketpp::client< debug_config_client > debug_client
Definition: connection.cpp:147
stub_config::con_msg_manager_type con_msg_manager_type
Definition: hybi13.cpp:89
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
bool is_server() const
Definition: connection.cpp:58
websocketpp::lib::error_code ec
Definition: connection.cpp:140
static char const user_agent[]
Default user agent string.
Definition: version.hpp:57
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
Definition: endpoint.hpp:643
HTTP handling support.
Definition: constants.hpp:39
connection_ptr connect(connection_ptr con)
Begin the connection process for the given connection.
void on_open_print(server *s, websocketpp::connection_hdl hdl)
Definition: connection.cpp:196
bool validate_set_ua(server *s, websocketpp::connection_hdl hdl)
Definition: connection.cpp:158
core::elog_type elog_type
Definition: connection.cpp:76
connection_extension connection_base
Definition: connection.cpp:128
core::con_msg_manager_type con_msg_manager_type
Definition: connection.cpp:95
core::alog_type alog_type
Definition: connection.cpp:98
debug_config_client type
Definition: connection.cpp:87
core::endpoint_msg_manager_type endpoint_msg_manager_type
Definition: connection.cpp:73
static level const none
Special aggregate value representing "no levels".
Definition: levels.hpp:114
core::endpoint_base endpoint_base
Definition: connection.cpp:127
void set_max_message_size(size_t new_value)
Set default maximum message size.
Definition: endpoint.hpp:432
Invalid WebSocket protocol version.
Definition: error.hpp:137
The connection was in the wrong state for this operation.
Definition: error.hpp:74
bool is_server() const
Get whether or not this connection is part of a server or client.
Server endpoint role based on the given config.
Thread safe stub "random" integer generator.
Definition: none.hpp:46
void clear_error_channels(log::level channels)
Clear Error logging channels.
Definition: endpoint.hpp:253
websocketpp::random::none::int_generator< uint32_t > rng_type
Definition: connection.cpp:101
void set_access_channels(log::level channels)
Set Access logging channel.
Definition: endpoint.hpp:220
Namespace for the WebSocket++ project.
Definition: base64.hpp:41
void set_http_handler(http_handler h)
Definition: endpoint.hpp:312
core::alog_type alog_type
Definition: connection.cpp:75
websocketpp::transport::debug::endpoint< transport_config > transport_type
Transport Endpoint Component.
Definition: connection.cpp:125
void defer_http_func(server *s, bool *deferred, websocketpp::connection_hdl hdl)
Definition: connection.cpp:178
void set_validate_handler(validate_handler h)
Definition: endpoint.hpp:317
void set_fail_handler(fail_handler h)
Definition: endpoint.hpp:287
websocketpp::lib::shared_ptr< stub_config::alog_type > alog
Definition: connection.cpp:141
core::concurrency_type concurrency_type
Definition: connection.cpp:66
core::response_type response_type
Definition: connection.cpp:92
connection_ptr get_connection()
Create and initialize a new connection.
std::string get_string(value code)
Return a human readable interpretation of a WebSocket close code.
Definition: close.hpp:232
core::request_type request_type
Definition: connection.cpp:68
void clear_access_channels(log::level channels)
Clear Access logging channels.
Definition: endpoint.hpp:231
core::message_type message_type
Definition: connection.cpp:94
void set_error_channels(log::level channels)
Set Error logging channel.
Definition: endpoint.hpp:242
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
BOOST_AUTO_TEST_CASE(basic_http_request)
Definition: connection.cpp:41
core::endpoint_msg_manager_type endpoint_msg_manager_type
Definition: connection.cpp:96
void check_on_fail(server *s, websocketpp::lib::error_code ec, bool &called, websocketpp::connection_hdl hdl)
Definition: connection.cpp:187
core::response_type response_type
Definition: connection.cpp:69
void set_user_agent(std::string const &ua)
Sets the user agent string that this endpoint will use.
Definition: endpoint.hpp:196
void echo_func(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
WebSocket opening handshake timed out.
Definition: error.hpp:114
uint32_t level
Type of a channel package.
Definition: levels.hpp:37
void set_message_handler(message_handler h)
Definition: endpoint.hpp:322
websocketpp::connection< stub_config > c
Definition: connection.cpp:144
static level const all
Special aggregate value representing "all levels".
Definition: levels.hpp:80
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)
connection_ptr get_connection(uri_ptr location, lib::error_code &ec)
Get a new connection.
Server config with iostream transport.
Definition: core.hpp:68
Unsupported WebSocket protocol version.
Definition: error.hpp:140
websocketpp::lib::shared_ptr< stub_config::elog_type > elog
Definition: connection.cpp:142
connection_setup(bool p_is_server)
Definition: connection.cpp:135