Fix some bugs, normalize code style, update documentation, add tests

Method needs to be public to be useful, updated return type to const
reference for efficiency
This commit is contained in:
Peter Thorson committed 2016-10-14 08:27:06 -05:00
1 parent e1f75756d1
commit abf927bb24
4 files changed
+26 -7

No files matched your search

+3
View File
@@ -4,6 +4,9 @@ HEAD
- Examples: Add `print_client_tls` example. This demonstrates a minimal TLS
client, including basic support via Asio+OpenSSL for certificate chain
and hostname verification.
- Feature: Add getter for all headers to the HTTP parsers. This allows a
wrapping library to enumerate all headers to send upstream. Thank you Jupp
Müller for reporting and an initial pull request.
- Improvement: Move the `socket_init_handler` to execute as a part of `init_asio`
rather than connection `pre_init`. This allows setting of socket options prior
to the bind/listen/accept system calls. Thank you ChristianRobl3D for
+12
View File
@@ -506,6 +506,18 @@ BOOST_AUTO_TEST_CASE( basic_request_with_body ) {
BOOST_CHECK_EQUAL( r.get_header("Host"), "www.example.com" );
BOOST_CHECK_EQUAL( r.get_header("Content-Length"), "5" );
BOOST_CHECK_EQUAL( r.get_body(), "abcde" );
BOOST_CHECK_EQUAL( r.get_headers().size(), 2);
websocketpp::http::parser::header_list::const_iterator it = r.get_headers().begin();
BOOST_CHECK_EQUAL( it->first, "Content-Length");
BOOST_CHECK_EQUAL( it->second, "5");
it++;
BOOST_CHECK_EQUAL( it->first, "Host");
BOOST_CHECK_EQUAL( it->second, "www.example.com");
}
BOOST_AUTO_TEST_CASE( basic_request_with_body_split ) {
+1 -1
View File
@@ -176,7 +176,7 @@ inline void parser::process_header(std::string::iterator begin,
strip_lws(std::string(cursor+sizeof(header_separator)-1,end)));
}
inline header_list headers() const {
inline header_list const & parser::get_headers() const {
return m_headers;
}
+10 -6
View File
@@ -441,6 +441,16 @@ public:
bool get_header_as_plist(std::string const & key, parameter_list & out)
const;
/// Return a list of all HTTP headers
/**
* Return a list of all HTTP headers
*
* @since 0.8.0
*
* @return A list of all HTTP headers
*/
header_list const & get_headers() const;
/// Append a value to an existing HTTP header
/**
* This method will set the value of the HTTP header `key` with the
@@ -590,12 +600,6 @@ protected:
return (m_body_bytes_needed == 0);
}
/// Return a list of all HTTP headers
/**
* Return a list of all HTTP headers
*/
header_list headers() const;
/// Generate and return the HTTP headers as a string
/**
* Each headers will be followed by the \r\n sequence including the last one.