if (packetLen > ((sizeof(dnsheader) + consumed))) {
if (!d_cookieHashing) {
/* skip EDNS Cookie options if any */
- result = PacketCache::hashAfterQname(string_view(reinterpret_cast<const char*>(packet), packetLen), result, sizeof(dnsheader) + consumed, false);
+ result = PacketCache::hashAfterQname(pdns_string_view(reinterpret_cast<const char*>(packet), packetLen), result, sizeof(dnsheader) + consumed, false);
}
else {
result = burtle(packet + sizeof(dnsheader) + consumed, packetLen - (sizeof(dnsheader) + consumed), result);
}
/* can only be called from the main DoH thread */
-static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, string_view& value)
+static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, pdns_string_view& value)
{
bool found = false;
/* early versions of boost::string_ref didn't have the ability to compare to string */
- string_view headerNameView(headerName);
+ pdns_string_view headerNameView(headerName);
for (size_t i = 0; i < req->headers.size; ++i) {
- if (string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) {
- value = string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len);
+ if (pdns_string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) {
+ value = pdns_string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len);
/* don't stop there, we might have more than one header with the same name, and we want the last one */
found = true;
}
static void processForwardedForHeader(const h2o_req_t* req, ComboAddress& remote)
{
static const std::string headerName = "x-forwarded-for";
- string_view value;
+ pdns_string_view value;
if (getHTTPHeaderValue(req, headerName, value)) {
try {
auto pos = value.rfind(',');
- if (pos != string_view::npos) {
+ if (pos != pdns_string_view::npos) {
++pos;
for (; pos < value.size() && value[pos] == ' '; ++pos)
{
- EDNS Cookie options, if any ;
- EDNS Client Subnet options, if any and skipECS is true.
*/
- static uint32_t hashAfterQname(const string_view& packet, uint32_t currentHash, size_t pos, bool skipECS)
+ static uint32_t hashAfterQname(const pdns_string_view& packet, uint32_t currentHash, size_t pos, bool skipECS)
{
const size_t packetSize = packet.size();
assert(packetSize >= sizeof(dnsheader));
#pragma once
#ifdef __cpp_lib_string_view
-using std::string_view;
+using pdns_string_view = std::string_view;
#else
#include <boost/version.hpp>
#if BOOST_VERSION >= 106400
// string_view already exists in 1.61.0 but string_view::at() is not usable with modern compilers, see:
// https://github.com/boostorg/utility/pull/26
#include <boost/utility/string_view.hpp>
-using boost::string_view;
+using pdns_string_view = boost::string_view;
#elif BOOST_VERSION >= 105300
#include <boost/utility/string_ref.hpp>
-using string_view = boost::string_ref;
+using pdns_string_view = boost::string_ref;
#else
-using string_view = std::string;
+using pdns_string_view = std::string;
#endif
#endif