Skip to content

Commit 2667209

Browse files
author
Peter Thorson
committed
Merge branch 'SophiaTX-set_body-move' into develop
# Conflicts: # websocketpp/connection.hpp # websocketpp/impl/connection_impl.hpp
2 parents 46ab940 + 180f83a commit 2667209

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/connection/connection.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
178192
void 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\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
259+
std::string output = "HTTP/1.1 200 OK\r\nContent-Length: 8\r\nServer: ";
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+
243269
BOOST_AUTO_TEST_CASE( deferred_http_request ) {
244270
std::string input = "GET /foo/bar HTTP/1.1\r\nHost: www.example.com\r\nOrigin: http://www.example.com\r\n\r\n";
245271
std::string output = "HTTP/1.1 200 OK\r\nContent-Length: 8\r\nServer: ";

0 commit comments

Comments
 (0)