@@ -175,6 +175,20 @@ void http_func(server* s, websocketpp::connection_hdl hdl) {
175175 BOOST_CHECK_EQUAL (con->get_response_msg (), status_code::get_string (status_code::ok));
176176}
177177
178+ void http_func_with_move (server* s, websocketpp::connection_hdl hdl) {
179+ using namespace websocketpp ::http;
180+
181+ server::connection_ptr con = s->get_con_from_hdl (hdl);
182+
183+ std::string res = con->get_resource ();
184+
185+ con->set_body (std::move (res));
186+ con->set_status (status_code::ok);
187+
188+ BOOST_CHECK_EQUAL (con->get_response_code (), status_code::ok);
189+ BOOST_CHECK_EQUAL (con->get_response_msg (), status_code::get_string (status_code::ok));
190+ }
191+
178192void defer_http_func (server* s, bool * deferred, websocketpp::connection_hdl hdl) {
179193 *deferred = true ;
180194
@@ -240,6 +254,18 @@ BOOST_AUTO_TEST_CASE( http_request ) {
240254 BOOST_CHECK_EQUAL (run_server_test (s,input), output);
241255}
242256
257+ BOOST_AUTO_TEST_CASE ( http_request_with_move ) {
258+ std::string input = " GET /foo/bar HTTP/1.1\r\n Host: www.example.com\r\n Origin: http://www.example.com\r\n\r\n " ;
259+ std::string output = " HTTP/1.1 200 OK\r\n Content-Length: 8\r\n Server: " ;
260+ output+=websocketpp::user_agent;
261+ output+=" \r\n\r\n /foo/bar" ;
262+
263+ server s;
264+ s.set_http_handler (bind (&http_func_with_move,&s,::_1));
265+
266+ BOOST_CHECK_EQUAL (run_server_test (s,input), output);
267+ }
268+
243269BOOST_AUTO_TEST_CASE ( deferred_http_request ) {
244270 std::string input = " GET /foo/bar HTTP/1.1\r\n Host: www.example.com\r\n Origin: http://www.example.com\r\n\r\n " ;
245271 std::string output = " HTTP/1.1 200 OK\r\n Content-Length: 8\r\n Server: " ;
0 commit comments