Add get_status and get_response methods to connection fixes #465

This commit is contained in:
Peter Thorson
2015-09-17 10:09:07 -04:00
parent 3e8dbf767d
commit 93b75ccc7d
2 changed files with 34 additions and 0 deletions
+3
View File
@@ -15,6 +15,9 @@ 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.
- 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.
+31
View File
@@ -969,6 +969,18 @@ public:
*/
std::string const & get_response_header(std::string const & key) const;
/// Get response status code and message
/**
* Gets the response status code
*
* @since 0.7.0
*
* @return The response status code sent
*/
http::status_code::value get_status() const {
return m_response->get_status();
}
/// Set response status code and message
/**
* Sets the response status code to `code` and looks up the corresponding
@@ -1076,6 +1088,25 @@ public:
return m_request;
}
/// Get response object
/**
* Direct access to the HTTP response sent or received as a part of the
* opening handshake. This can be used to call methods of the response
* object that are not part of the standard request API that connection
* wraps.
*
* Note use of this method involves using behavior specific to the
* configured HTTP policy. Such behavior may not work with alternate HTTP
* policies.
*
* @since 0.7.0
*
* @return A const reference to the raw response object
*/
response_type const & get_response() const {
return m_response;
}
/// Defer HTTP Response until later (Exception free)
/**
* Used in the http handler to defer the HTTP response for this connection