update code style and add docs+tests for uri::get_query references #298

This commit is contained in:
Peter Thorson
2013-10-20 14:15:05 -05:00
parent 4d51d990a4
commit 962a090300
3 changed files with 16 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
HEAD
- Adds URI method to extract query string from URI.
- Numerous performance improvements. Including: tuned default buffer sizes based
on profiling, caching of handler binding for async reads/writes, non-malloc
allocators for read/write handlers, disabling of a number of questionably

View File

@@ -43,6 +43,7 @@ BOOST_AUTO_TEST_CASE( uri_valid ) {
BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
BOOST_CHECK_EQUAL( uri.get_query(), "" );
}
// Test a regular valid ws URI
@@ -201,6 +202,7 @@ BOOST_AUTO_TEST_CASE( uri_valid_4 ) {
BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
BOOST_CHECK_EQUAL( uri.get_resource(), "/chat/foo/bar?foo=bar" );
BOOST_CHECK_EQUAL( uri.get_query(), "foo=bar" );
}
// Valid URI with a mapped v4 ipv6 literal

View File

@@ -281,16 +281,23 @@ public:
s << m_resource;
return s.str();
}
std::string const get_query() const {
std::size_t found = m_resource.find("?");
if (found > 0)
/// Return the query portion
/**
* Returns the query portion (after the ?) of the URI or an empty string if
* there is none.
*
* @return query portion of the URI.
*/
std::string get_query() const {
std::size_t found = m_resource.find('?');
if (found != std::string::npos) {
return m_resource.substr(found + 1);
else
} else {
return "";
}
}
// get query?
// get fragment
// hi <3