Actually have the response status getters work; also tests

This commit is contained in:
Peter Thorson
2015-09-19 10:54:50 -04:00
parent 72e55a76b5
commit b6817e4c7e
3 changed files with 25 additions and 7 deletions
+4 -3
View File
@@ -15,9 +15,10 @@ HEAD
`pass_through` error type.
- Improvement: Add a `get_transport_error` method to Asio transport connections
to allow retrieving a machine readable native transport error.
- Improvement: Add `connection::get_status` and `connection::get_response`
methods to allow accessing additional information about the HTTP responses
that WebSocket++ sends. #465 Thank you Flow86 for reporting.
- Improvement: Add `connection::get_response`, `connection::get_response_code`,
and `connection::get_response_msg` methods to allow accessing additional
information about the HTTP responses that WebSocket++ sends. #465 Thank you
Flow86 for reporting.
- Documentation: Adds an example demonstrating the use of external `io_service`
- Bug: Fix memory leak when init_asio produces an error. #454 Thank you Mark
Grimes for reporting and fixing.
+6 -1
View File
@@ -159,12 +159,17 @@ bool validate_set_ua(server* s, websocketpp::connection_hdl hdl) {
}
void http_func(server* s, websocketpp::connection_hdl hdl) {
using namespace websocketpp::http;
server::connection_ptr con = s->get_con_from_hdl(hdl);
std::string res = con->get_resource();
con->set_body(res);
con->set_status(websocketpp::http::status_code::ok);
con->set_status(status_code::ok);
BOOST_CHECK_EQUAL(con->get_response_code(), status_code::ok);
BOOST_CHECK_EQUAL(con->get_response_msg(), status_code::get_string(status_code::ok));
}
void defer_http_func(server* s, bool * deferred, websocketpp::connection_hdl hdl) {
+15 -3
View File
@@ -969,7 +969,7 @@ public:
*/
std::string const & get_response_header(std::string const & key) const;
/// Get response status code and message
/// Get response HTTP status code
/**
* Gets the response status code
*
@@ -977,10 +977,22 @@ public:
*
* @return The response status code sent
*/
http::status_code::value get_status() const {
return m_response->get_status();
http::status_code::value get_response_code() const {
return m_response.get_status_code();
}
/// Get response HTTP status message
/**
* Gets the response status message
*
* @since 0.7.0
*
* @return The response status message sent
*/
std::string const & get_response_msg() const {
return m_response.get_status_msg();
}
/// Set response status code and message
/**
* Sets the response status code to `code` and looks up the corresponding