39 {
43
44 std::string handshake = "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nOrigin: http://example.com\r\nSec-WebSocket-Key1: 3e6b263 4 17 80\r\nSec-WebSocket-Key2: 17 9 G`ZD9 2 2b 7X 3 /r90\r\n\r\n";
45
46 r.consume(handshake.c_str(),handshake.size());
47 r.replace_header(
"Sec-WebSocket-Key3",
"WjN}|M(6");
48
51 BOOST_CHECK(
p.validate_handshake(
r));
52
54 bool exception;
55
56 try {
58 } catch (const websocketpp::uri_exception& e) {
59 exception = true;
60 }
61
62 BOOST_CHECK(exception == false);
63 BOOST_CHECK(u->get_secure() == false);
64 BOOST_CHECK(u->get_host() == "www.example.com");
65 BOOST_CHECK(u->get_resource() == "/");
66 BOOST_CHECK(u->get_port() == websocketpp::URI_DEFAULT_PORT);
67
68 p.process_handshake(
r,response);
69
70 BOOST_CHECK(response.get_header("Connection") == "Upgrade");
71 BOOST_CHECK(response.get_header("Upgrade") == "websocket");
72 BOOST_CHECK(response.get_header("Sec-WebSocket-Origin") == "http://example.com");
73
74 BOOST_CHECK(response.get_header("Sec-WebSocket-Location") == "ws://www.example.com/");
75 BOOST_CHECK(response.get_header("Sec-WebSocket-Key3") == "n`9eBk9z$R8pOtVb");
76}
Stores, parses, and manipulates HTTP responses.