66 {
68
69 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";
70
71 env.req.consume(handshake.c_str(),handshake.size());
72 env.req.replace_header("Sec-WebSocket-Key3","WjN}|M(6");
73
76 env.ec = env.p.validate_handshake(env.req);
77 BOOST_CHECK(!env.ec);
78
80
81 BOOST_CHECK_NO_THROW( u = env.p.get_uri(env.req) );
82
83 BOOST_CHECK_EQUAL(u->get_secure(), false);
84 BOOST_CHECK_EQUAL(u->get_host(), "www.example.com");
85 BOOST_CHECK_EQUAL(u->get_resource(), "/");
86 BOOST_CHECK_EQUAL(u->get_port(), websocketpp::uri_default_port);
87
88 env.p.process_handshake(env.req,"",env.res);
89
90 BOOST_CHECK_EQUAL(env.res.get_header("Connection"), "Upgrade");
91 BOOST_CHECK_EQUAL(env.res.get_header("Upgrade"), "WebSocket");
92 BOOST_CHECK_EQUAL(env.res.get_header("Sec-WebSocket-Origin"), "http://example.com");
93
94 BOOST_CHECK_EQUAL(env.res.get_header("Sec-WebSocket-Location"), "ws://www.example.com/");
95 BOOST_CHECK_EQUAL(env.res.get_header("Sec-WebSocket-Key3"), "n`9eBk9z$R8pOtVb");
96}