6#include <boost/beast/core/string.hpp>
7#include <boost/beast/http/message.hpp>
14 template<
bool isReq,
typename Fields>
17 resource_string(
const boost::beast::http::header<isReq, Fields>& header)
19 const auto target = header.target();
21 const auto pos = target.find_first_of(
"?#");
22 if (pos == std::string::npos)
25 return target.substr(0, pos);
28 template<
bool isReq,
typename Fields>
30 chop_resource(boost::beast::http::header<isReq, Fields>& head, std::string_view resource)
32 head.target(head.target().substr(resource.size()));
35 template<
bool isReq,
typename Fields>
38 has_field(
const boost::beast::http::header<isReq, Fields>& head,
const malloy::http::field check)
40 return head.find(check) != head.end();
59 std::vector<std::string_view>
62 using namespace std::string_view_literals;
79 template<
bool isReq,
typename Fields>
81 std::optional<std::string_view>
82 cookie_value(
const boost::beast::http::header<isReq, Fields>& header,
const std::string_view cookie_name)
84 using namespace std::string_view_literals;
87 const auto& it = header.find(field::cookie);
88 if (it == header.cend())
95 for (
const std::string_view& pair : pairs) {
98 if (parts.size() != 2)
102 if (parts[0] == cookie_name)
std::optional< std::string_view > cookie_value(const boost::beast::http::header< isReq, Fields > &header, const std::string_view cookie_name)
Definition: utils.hpp:82
boost::beast::http::field field
Definition: types.hpp:28
std::vector< std::string_view > split_header_value(std::string_view field_value)
Definition: utils.hpp:60
std::vector< std::string_view > split(std::string_view str, std::string_view delimiter)
Definition: utils.hpp:86