diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index a4dcd02ba1..08a9242654 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -571,6 +571,22 @@ public: // Pass-through access to the request and response objects // ///////////////////////////////////////////////////////////// + /// Retrieve a request header + /** + * Retrieve the value of a header from the handshake HTTP request. + * + * @param key Name of the header to get + */ + const std::string & get_request_header(const std::string &key); + + /// Retrieve a response header + /** + * Retrieve the value of a header from the handshake HTTP request. + * + * @param key Name of the header to get + */ + const std::string & get_response_header(const std::string &key); + /// Set response status code and message /** * Sets the response status code to `code` and looks up the corresponding diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 8328f6c426..d7a7af3afb 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -359,6 +359,19 @@ void connection::select_subprotocol(const std::string & value) { } } + +template +const std::string & +connection::get_request_header(const std::string &key) { + return m_request.get_header(key); +} + +template +const std::string & +connection::get_response_header(const std::string &key) { + return m_response.get_header(key); +} + template void connection::set_status( http::status_code::value code)