Qualify calls to beast::iequals in basic_parser.ipp

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
Damian Jarek
2019-06-21 20:58:17 +02:00
parent 50ce5f7396
commit 1a720c8354
7 changed files with 27 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
Version 260: Version 260:
* More split compilation in rfc7230.hpp * More split compilation in rfc7230.hpp
* Qualify calls to `beast::iequals` in basic_parser.ipp
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -17,6 +17,10 @@ namespace beast {
namespace detail { namespace detail {
// Pulling in the UDL directly breaks in some places on MSVC,
// so introduce a namespace for this purprose.
namespace string_literals {
inline inline
string_view string_view
operator"" _sv(char const* p, std::size_t n) operator"" _sv(char const* p, std::size_t n)
@@ -24,6 +28,8 @@ operator"" _sv(char const* p, std::size_t n)
return string_view{p, n}; return string_view{p, n};
} }
} // string_literals
inline inline
char char
ascii_tolower(char c) ascii_tolower(char c)

View File

@@ -16,6 +16,7 @@
#include <boost/beast/core/buffer_traits.hpp> #include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/detail/clamp.hpp> #include <boost/beast/core/detail/clamp.hpp>
#include <boost/beast/core/detail/config.hpp> #include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/string.hpp>
#include <boost/asio/buffer.hpp> #include <boost/asio/buffer.hpp>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
@@ -746,6 +747,7 @@ basic_parser<isRequest>::
do_field(field f, do_field(field f,
string_view value, error_code& ec) string_view value, error_code& ec)
{ {
using namespace beast::detail::string_literals;
// Connection // Connection
if(f == field::connection || if(f == field::connection ||
f == field::proxy_connection) f == field::proxy_connection)
@@ -759,19 +761,19 @@ do_field(field f,
} }
for(auto const& s : list) for(auto const& s : list)
{ {
if(iequals({"close", 5}, s)) if(beast::iequals("close"_sv, s))
{ {
f_ |= flagConnectionClose; f_ |= flagConnectionClose;
continue; continue;
} }
if(iequals({"keep-alive", 10}, s)) if(beast::iequals("keep-alive"_sv, s))
{ {
f_ |= flagConnectionKeepAlive; f_ |= flagConnectionKeepAlive;
continue; continue;
} }
if(iequals({"upgrade", 7}, s)) if(beast::iequals("upgrade"_sv, s))
{ {
f_ |= flagConnectionUpgrade; f_ |= flagConnectionUpgrade;
continue; continue;
@@ -832,9 +834,9 @@ do_field(field f,
ec = {}; ec = {};
auto const v = token_list{value}; auto const v = token_list{value};
auto const p = std::find_if(v.begin(), v.end(), auto const p = std::find_if(v.begin(), v.end(),
[&](typename token_list::value_type const& s) [&](string_view const& s)
{ {
return iequals({"chunked", 7}, s); return beast::iequals("chunked"_sv, s);
}); });
if(p == v.end()) if(p == v.end())
return; return;

View File

@@ -577,7 +577,7 @@ insert(field name,
} }
auto const last = std::prev(before); auto const last = std::prev(before);
// VFALCO is it worth comparing `field name` first? // VFALCO is it worth comparing `field name` first?
if(! iequals(sname, last->name_string())) if(! beast::iequals(sname, last->name_string()))
{ {
BOOST_ASSERT(count(sname) == 0); BOOST_ASSERT(count(sname) == 0);
set_.insert_before(before, e); set_.insert_before(before, e);
@@ -818,7 +818,7 @@ get_chunked_impl() const
{ {
auto const next = std::next(it); auto const next = std::next(it);
if(next == te.end()) if(next == te.end())
return iequals(*it, "chunked"); return beast::iequals(*it, "chunked");
it = next; it = next;
} }
return false; return false;
@@ -901,7 +901,7 @@ set_chunked_impl(bool value)
auto const next = std::next(itt); auto const next = std::next(itt);
if(next == te.end()) if(next == te.end())
{ {
if(iequals(*itt, "chunked")) if(beast::iequals(*itt, "chunked"))
return; // already set return; // already set
break; break;
} }
@@ -1001,7 +1001,7 @@ set_element(element& e)
{ {
auto it = set_.lower_bound( auto it = set_.lower_bound(
e.name_string(), key_compare{}); e.name_string(), key_compare{});
if(it == set_.end() || ! iequals( if(it == set_.end() || ! beast::iequals(
e.name_string(), it->name_string())) e.name_string(), it->name_string()))
{ {
set_.insert_before(it, e); set_.insert_before(it, e);
@@ -1017,7 +1017,7 @@ set_element(element& e)
delete_element(*it); delete_element(*it);
it = next; it = next;
if(it == set_.end() || if(it == set_.end() ||
! iequals(e.name_string(), it->name_string())) ! beast::iequals(e.name_string(), it->name_string()))
break; break;
} }
set_.insert_before(it, e); set_.insert_before(it, e);

View File

@@ -21,7 +21,7 @@ namespace http {
string_view string_view
to_string(verb v) to_string(verb v)
{ {
using beast::detail::operator "" _sv; using namespace beast::detail::string_literals;
switch(v) switch(v)
{ {
case verb::delete_: return "DELETE"_sv; case verb::delete_: return "DELETE"_sv;
@@ -109,7 +109,7 @@ string_to_verb(string_view v)
UNLOCK UNLOCK
UNSUBSCRIBE UNSUBSCRIBE
*/ */
using beast::detail::operator "" _sv; using namespace beast::detail::string_literals;
if(v.size() < 3) if(v.size() < 3)
return verb::unknown; return verb::unknown;
auto c = v[0]; auto c = v[0];

View File

@@ -47,7 +47,7 @@ make_sec_ws_accept(
string_view key) string_view key)
{ {
BOOST_ASSERT(key.size() <= sec_ws_key_type::max_size_n); BOOST_ASSERT(key.size() <= sec_ws_key_type::max_size_n);
using beast::detail::operator "" _sv; using namespace beast::detail::string_literals;
auto const guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"_sv; auto const guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"_sv;
beast::detail::sha1_context ctx; beast::detail::sha1_context ctx;
beast::detail::init(ctx); beast::detail::init(ctx);

View File

@@ -52,11 +52,11 @@ pmd_read_impl(pmd_offer& offer, http::ext_list const& list)
for(auto const& ext : list) for(auto const& ext : list)
{ {
if(iequals(ext.first, "permessage-deflate")) if(beast::iequals(ext.first, "permessage-deflate"))
{ {
for(auto const& param : ext.second) for(auto const& param : ext.second)
{ {
if(iequals(param.first, if(beast::iequals(param.first,
"server_max_window_bits")) "server_max_window_bits"))
{ {
if(offer.server_max_window_bits != 0) if(offer.server_max_window_bits != 0)
@@ -84,7 +84,7 @@ pmd_read_impl(pmd_offer& offer, http::ext_list const& list)
return; // MUST decline return; // MUST decline
} }
} }
else if(iequals(param.first, else if(beast::iequals(param.first,
"client_max_window_bits")) "client_max_window_bits"))
{ {
if(offer.client_max_window_bits != 0) if(offer.client_max_window_bits != 0)
@@ -112,7 +112,7 @@ pmd_read_impl(pmd_offer& offer, http::ext_list const& list)
offer.client_max_window_bits = -1; offer.client_max_window_bits = -1;
} }
} }
else if(iequals(param.first, else if(beast::iequals(param.first,
"server_no_context_takeover")) "server_no_context_takeover"))
{ {
if(offer.server_no_context_takeover) if(offer.server_no_context_takeover)
@@ -131,7 +131,7 @@ pmd_read_impl(pmd_offer& offer, http::ext_list const& list)
} }
offer.server_no_context_takeover = true; offer.server_no_context_takeover = true;
} }
else if(iequals(param.first, else if(beast::iequals(param.first,
"client_no_context_takeover")) "client_no_context_takeover"))
{ {
if(offer.client_no_context_takeover) if(offer.client_no_context_takeover)