_ZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEE:
10240|    507|inline bool parse_range_header(const std::string &s, Ranges &ranges) try {
10241|    507|#endif
10242|    507|  auto is_valid = [](const std::string &str) {
10243|    507|    return std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
10244|    507|  };
10245|       |
10246|    507|  if (s.size() > 7 && case_ignore::equal(s.substr(0, 6), "bytes=")) {
  ------------------
  |  Branch (10246:7): [True: 504, False: 3]
  |  Branch (10246:7): [True: 487, False: 20]
  |  Branch (10246:23): [True: 487, False: 17]
  ------------------
10247|    487|    const auto pos = static_cast<size_t>(6);
10248|    487|    const auto len = static_cast<size_t>(s.size() - 6);
10249|    487|    auto all_valid_ranges = true;
10250|    487|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
10251|    487|      if (!all_valid_ranges) { return; }
10252|       |
10253|    487|      const auto it = std::find(b, e, '-');
10254|    487|      if (it == e) {
10255|    487|        all_valid_ranges = false;
10256|    487|        return;
10257|    487|      }
10258|       |
10259|    487|      const auto lhs = std::string(b, it);
10260|    487|      const auto rhs = std::string(it + 1, e);
10261|    487|      if (!is_valid(lhs) || !is_valid(rhs)) {
10262|    487|        all_valid_ranges = false;
10263|    487|        return;
10264|    487|      }
10265|       |
10266|    487|      ssize_t first = -1;
10267|    487|      if (!lhs.empty()) {
10268|       |        // Reject an overflowing first-byte-pos; treating it as absent (-1)
10269|       |        // would turn the range into a suffix range.
10270|    487|        auto res =
10271|    487|            detail::from_chars(lhs.data(), lhs.data() + lhs.size(), first);
10272|    487|        if (res.ec != std::errc{}) {
10273|    487|          all_valid_ranges = false;
10274|    487|          return;
10275|    487|        }
10276|    487|      }
10277|       |
10278|    487|      ssize_t last = -1;
10279|    487|      if (!rhs.empty()) {
10280|       |        // An overflowing last-byte-pos is past any content length, so keeping
10281|       |        // -1 ("remainder", RFC 9110 14.1.2) is correct here.
10282|    487|        ssize_t v;
10283|    487|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
10284|    487|        if (res.ec == std::errc{}) { last = v; }
10285|    487|      }
10286|       |
10287|    487|      if ((first == -1 && last == -1) ||
10288|    487|          (first != -1 && last != -1 && first > last)) {
10289|    487|        all_valid_ranges = false;
10290|    487|        return;
10291|    487|      }
10292|       |
10293|    487|      ranges.emplace_back(first, last);
10294|    487|    });
10295|    487|    return all_valid_ranges && !ranges.empty();
  ------------------
  |  Branch (10295:12): [True: 284, False: 203]
  |  Branch (10295:32): [True: 284, False: 0]
  ------------------
10296|    487|  }
10297|     20|  return false;
10298|       |#ifdef CPPHTTPLIB_NO_EXCEPTIONS
10299|       |}
10300|       |#else
10301|    507|} catch (...) { return false; }
_ZN7httplib6detail11case_ignore5equalILm7EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|    504|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|    504|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 504, False: 0]
  ------------------
  729|    504|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 487, False: 17]
  ------------------
  730|    504|           return to_lower(ca) == to_lower(cb);
  731|    504|         });
  732|    504|}
_ZZN7httplib6detail11case_ignore5equalILm7EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  2.96k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  2.96k|           return to_lower(ca) == to_lower(cb);
  731|  2.96k|         });
_ZN7httplib6detail11case_ignore8to_lowerEi:
  686|  27.9M|inline unsigned char to_lower(int c) {
  687|  27.9M|  const static unsigned char table[256] = {
  688|  27.9M|      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  689|  27.9M|      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  690|  27.9M|      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  691|  27.9M|      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  692|  27.9M|      60,  61,  62,  63,  64,  97,  98,  99,  100, 101, 102, 103, 104, 105, 106,
  693|  27.9M|      107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
  694|  27.9M|      122, 91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  695|  27.9M|      105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  696|  27.9M|      120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  697|  27.9M|      135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  698|  27.9M|      150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  699|  27.9M|      165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  700|  27.9M|      180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 224, 225, 226,
  701|  27.9M|      227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
  702|  27.9M|      242, 243, 244, 245, 246, 215, 248, 249, 250, 251, 252, 253, 254, 223, 224,
  703|  27.9M|      225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  704|  27.9M|      240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  705|  27.9M|      255,
  706|  27.9M|  };
  707|  27.9M|  return table[(unsigned char)(char)c];
  708|  27.9M|}
_ZN7httplib6detail5splitEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 6732|  2.02k|                  std::function<void(const char *, const char *)> fn) {
 6733|  2.02k|  return split(b, e, d, (std::numeric_limits<size_t>::max)(), std::move(fn));
 6734|  2.02k|}
_ZN7httplib6detail5splitEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 6737|  2.02k|                  std::function<void(const char *, const char *)> fn) {
 6738|  2.02k|  size_t i = 0;
 6739|  2.02k|  size_t beg = 0;
 6740|  2.02k|  size_t count = 1;
 6741|       |
 6742|  56.1M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6742:10): [True: 56.1M, False: 0]
  |  Branch (6742:10): [True: 56.1M, False: 2.02k]
  ------------------
 6743|  56.1M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6743:9): [True: 13.6M, False: 42.5M]
  |  Branch (6743:22): [True: 13.6M, False: 0]
  ------------------
 6744|  13.6M|      auto r = trim(b, e, beg, i);
 6745|  13.6M|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6745:11): [True: 8.93M, False: 4.69M]
  ------------------
 6746|  13.6M|      beg = i + 1;
 6747|  13.6M|      count++;
 6748|  13.6M|    }
 6749|  56.1M|    i++;
 6750|  56.1M|  }
 6751|       |
 6752|  2.02k|  if (i) {
  ------------------
  |  Branch (6752:7): [True: 2.02k, False: 0]
  ------------------
 6753|  2.02k|    auto r = trim(b, e, beg, i);
 6754|  2.02k|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6754:9): [True: 1.83k, False: 188]
  ------------------
 6755|  2.02k|  }
 6756|  2.02k|}
_ZN7httplib6detail4trimEPKcS2_mm:
 6672|  55.9M|                                      size_t right) {
 6673|  61.2M|  while (b + left < e && is_space_or_tab(b[left])) {
  ------------------
  |  Branch (6673:10): [True: 61.1M, False: 96.8k]
  |  Branch (6673:26): [True: 5.34M, False: 55.8M]
  ------------------
 6674|  5.34M|    left++;
 6675|  5.34M|  }
 6676|  61.2M|  while (right > 0 && is_space_or_tab(b[right - 1])) {
  ------------------
  |  Branch (6676:10): [True: 61.2M, False: 96.0k]
  |  Branch (6676:23): [True: 5.37M, False: 55.8M]
  ------------------
 6677|  5.37M|    right--;
 6678|  5.37M|  }
 6679|  55.9M|  return std::make_pair(left, right);
 6680|  55.9M|}
_ZN7httplib6detail15is_space_or_tabEc:
 6525|   122M|inline bool is_space_or_tab(char c) { return c == ' ' || c == '\t'; }
  ------------------
  |  Branch (6525:46): [True: 10.7M, False: 111M]
  |  Branch (6525:58): [True: 20.3k, False: 111M]
  ------------------
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlPKcSH_E_clESH_SH_:
10250|  73.8k|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
10251|  73.8k|      if (!all_valid_ranges) { return; }
  ------------------
  |  Branch (10251:11): [True: 10.9k, False: 62.8k]
  ------------------
10252|       |
10253|  62.8k|      const auto it = std::find(b, e, '-');
10254|  62.8k|      if (it == e) {
  ------------------
  |  Branch (10254:11): [True: 14, False: 62.8k]
  ------------------
10255|     14|        all_valid_ranges = false;
10256|     14|        return;
10257|     14|      }
10258|       |
10259|  62.8k|      const auto lhs = std::string(b, it);
10260|  62.8k|      const auto rhs = std::string(it + 1, e);
10261|  62.8k|      if (!is_valid(lhs) || !is_valid(rhs)) {
  ------------------
  |  Branch (10261:11): [True: 5, False: 62.8k]
  |  Branch (10261:29): [True: 11, False: 62.8k]
  ------------------
10262|     16|        all_valid_ranges = false;
10263|     16|        return;
10264|     16|      }
10265|       |
10266|  62.8k|      ssize_t first = -1;
10267|  62.8k|      if (!lhs.empty()) {
  ------------------
  |  Branch (10267:11): [True: 62.4k, False: 451]
  ------------------
10268|       |        // Reject an overflowing first-byte-pos; treating it as absent (-1)
10269|       |        // would turn the range into a suffix range.
10270|  62.4k|        auto res =
10271|  62.4k|            detail::from_chars(lhs.data(), lhs.data() + lhs.size(), first);
10272|  62.4k|        if (res.ec != std::errc{}) {
  ------------------
  |  Branch (10272:13): [True: 49, False: 62.3k]
  ------------------
10273|     49|          all_valid_ranges = false;
10274|     49|          return;
10275|     49|        }
10276|  62.4k|      }
10277|       |
10278|  62.8k|      ssize_t last = -1;
10279|  62.8k|      if (!rhs.empty()) {
  ------------------
  |  Branch (10279:11): [True: 1.13k, False: 61.6k]
  ------------------
10280|       |        // An overflowing last-byte-pos is past any content length, so keeping
10281|       |        // -1 ("remainder", RFC 9110 14.1.2) is correct here.
10282|  1.13k|        ssize_t v;
10283|  1.13k|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
10284|  1.13k|        if (res.ec == std::errc{}) { last = v; }
  ------------------
  |  Branch (10284:13): [True: 847, False: 283]
  ------------------
10285|  1.13k|      }
10286|       |
10287|  62.8k|      if ((first == -1 && last == -1) ||
  ------------------
  |  Branch (10287:12): [True: 451, False: 62.3k]
  |  Branch (10287:27): [True: 41, False: 410]
  ------------------
10288|  62.7k|          (first != -1 && last != -1 && first > last)) {
  ------------------
  |  Branch (10288:12): [True: 62.3k, False: 410]
  |  Branch (10288:27): [True: 437, False: 61.9k]
  |  Branch (10288:41): [True: 83, False: 354]
  ------------------
10289|    124|        all_valid_ranges = false;
10290|    124|        return;
10291|    124|      }
10292|       |
10293|  62.6k|      ranges.emplace_back(first, last);
10294|  62.6k|    });
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlS9_E_clES9_:
10242|   125k|  auto is_valid = [](const std::string &str) {
10243|   125k|    return std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
10244|   125k|  };
_ZN7httplib6detail14is_ascii_digitEc:
  674|   202k|inline bool is_ascii_digit(char c) { return '0' <= c && c <= '9'; }
  ------------------
  |  Branch (674:45): [True: 196k, False: 6.22k]
  |  Branch (674:57): [True: 196k, False: 400]
  ------------------
_ZN7httplib6detail10from_charsIlEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  795|  63.5k|                                       T &value, int base = 10) {
  796|  63.5k|  value = 0;
  797|  63.5k|  const char *p = first;
  798|  63.5k|  bool negative = false;
  799|       |
  800|  63.5k|  if (p != last && *p == '-') {
  ------------------
  |  Branch (800:7): [True: 63.5k, False: 0]
  |  Branch (800:20): [True: 0, False: 63.5k]
  ------------------
  801|      0|    negative = true;
  802|      0|    ++p;
  803|      0|  }
  804|  63.5k|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (804:7): [True: 0, False: 63.5k]
  ------------------
  805|       |
  806|  63.5k|  auto radix = static_cast<T>(base);
  807|  63.5k|  T result = 0;
  808|   136k|  for (; p != last; ++p) {
  ------------------
  |  Branch (808:10): [True: 73.7k, False: 63.2k]
  ------------------
  809|  73.7k|    char c = *p;
  810|  73.7k|    int digit = -1;
  811|  73.7k|    if (is_ascii_digit(c)) {
  ------------------
  |  Branch (811:9): [True: 73.7k, False: 0]
  ------------------
  812|  73.7k|      digit = c - '0';
  813|  73.7k|    } else if ('a' <= c && c <= 'z') {
  ------------------
  |  Branch (813:16): [True: 0, False: 0]
  |  Branch (813:28): [True: 0, False: 0]
  ------------------
  814|      0|      digit = c - 'a' + 10;
  815|      0|    } else if ('A' <= c && c <= 'Z') {
  ------------------
  |  Branch (815:16): [True: 0, False: 0]
  |  Branch (815:28): [True: 0, False: 0]
  ------------------
  816|      0|      digit = c - 'A' + 10;
  817|      0|    } else {
  818|      0|      break;
  819|      0|    }
  820|       |
  821|  73.7k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (821:9): [True: 0, False: 73.7k]
  |  Branch (821:22): [True: 0, False: 73.7k]
  ------------------
  822|  73.7k|    auto d = static_cast<T>(digit);
  823|  73.7k|    if (result > ((std::numeric_limits<T>::max)() - d) / radix) {
  ------------------
  |  Branch (823:9): [True: 332, False: 73.4k]
  ------------------
  824|    332|      return {p, std::errc::result_out_of_range};
  825|    332|    }
  826|  73.4k|    result = result * radix + d;
  827|  73.4k|  }
  828|       |
  829|  63.2k|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (829:7): [True: 0, False: 63.2k]
  |  Branch (829:22): [True: 0, False: 63.2k]
  |  Branch (829:34): [True: 0, False: 0]
  ------------------
  830|      0|    return {first, std::errc::invalid_argument};
  831|      0|  }
  832|       |
  833|  63.2k|  value = negative ? T(0) - result : result;
  ------------------
  |  Branch (833:11): [True: 0, False: 63.2k]
  ------------------
  834|  63.2k|  return {p, std::errc{}};
  835|  63.2k|}
_ZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEE:
10321|  1.72k|                                std::vector<std::string> &content_types) {
10322|       |  // Parameter values are not used here, so a quoted-string is dropped rather
10323|       |  // than parsed: a ',' or ';' inside one must not be read as a delimiter.
10324|  1.72k|  if (s.find('"') != std::string::npos) {
  ------------------
  |  Branch (10324:7): [True: 148, False: 1.57k]
  ------------------
10325|    148|    return parse_accept_header(remove_quoted_strings(s), content_types);
10326|    148|  }
10327|       |
10328|  1.57k|  content_types.clear();
10329|       |
10330|       |  // Empty string is considered valid (no preference)
10331|  1.57k|  if (s.empty()) { return true; }
  ------------------
  |  Branch (10331:7): [True: 43, False: 1.53k]
  ------------------
10332|       |
10333|  1.53k|  struct AcceptEntry {
10334|  1.53k|    std::string media_type;
10335|  1.53k|    double quality;
10336|  1.53k|    int order;
10337|  1.53k|  };
10338|       |
10339|  1.53k|  std::vector<AcceptEntry> entries;
10340|  1.53k|  int order = 0;
10341|  1.53k|  bool has_invalid_entry = false;
10342|       |
10343|       |  // Split by comma and parse each entry. RFC 9110 Section 5.6.1.2: a recipient
10344|       |  // has to parse and ignore empty list elements, so a leading, trailing or
10345|       |  // doubled comma must not turn a legal Accept value into 400 Bad Request.
10346|       |  // split() skips them, and the header length limit bounds how many a sender
10347|       |  // can send, so ignoring all of them cannot be used as a denial-of-service
10348|       |  // vector.
10349|  1.53k|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
10350|  1.53k|    std::string entry(b, e);
10351|  1.53k|    entry = trim_copy(entry);
10352|       |
10353|  1.53k|    AcceptEntry accept_entry;
10354|  1.53k|    accept_entry.order = order++;
10355|       |
10356|  1.53k|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
10357|  1.53k|                       accept_entry.media_type, accept_entry.quality)) {
10358|  1.53k|      has_invalid_entry = true;
10359|  1.53k|      return;
10360|  1.53k|    }
10361|       |
10362|       |    // Remove additional parameters from media type
10363|  1.53k|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
10364|       |
10365|       |    // Basic validation of media type format
10366|  1.53k|    if (accept_entry.media_type.empty()) {
10367|  1.53k|      has_invalid_entry = true;
10368|  1.53k|      return;
10369|  1.53k|    }
10370|       |
10371|       |    // Check for basic media type format (should contain '/' or be '*')
10372|  1.53k|    if (accept_entry.media_type != "*" &&
10373|  1.53k|        accept_entry.media_type.find('/') == std::string::npos) {
10374|  1.53k|      has_invalid_entry = true;
10375|  1.53k|      return;
10376|  1.53k|    }
10377|       |
10378|  1.53k|    entries.push_back(std::move(accept_entry));
10379|  1.53k|  });
10380|       |
10381|       |  // Return false if any invalid entry was found
10382|  1.53k|  if (has_invalid_entry) { return false; }
  ------------------
  |  Branch (10382:7): [True: 699, False: 836]
  ------------------
10383|       |
10384|       |  // Sort by quality (descending), then by original order (ascending)
10385|    836|  std::sort(entries.begin(), entries.end(),
10386|    836|            [](const AcceptEntry &a, const AcceptEntry &b) {
10387|    836|              if (a.quality != b.quality) {
10388|    836|                return a.quality > b.quality; // Higher quality first
10389|    836|              }
10390|    836|              return a.order < b.order; // Earlier order first for same quality
10391|    836|            });
10392|       |
10393|       |  // Extract sorted media types
10394|    836|  content_types.reserve(entries.size());
10395|  7.30M|  for (auto &entry : entries) {
  ------------------
  |  Branch (10395:20): [True: 7.30M, False: 836]
  ------------------
10396|  7.30M|    content_types.push_back(std::move(entry.media_type));
10397|  7.30M|  }
10398|       |
10399|    836|  return true;
10400|  1.53k|}
_ZN7httplib6detail21remove_quoted_stringsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
10305|    148|inline std::string remove_quoted_strings(const std::string &s) {
10306|    148|  std::string out;
10307|    148|  auto in_quotes = false;
10308|  8.34M|  for (size_t i = 0; i < s.size(); i++) {
  ------------------
  |  Branch (10308:22): [True: 8.34M, False: 148]
  ------------------
10309|  8.34M|    if (s[i] == '"') {
  ------------------
  |  Branch (10309:9): [True: 1.49k, False: 8.34M]
  ------------------
10310|  1.49k|      in_quotes = !in_quotes;
10311|  8.34M|    } else if (!in_quotes) {
  ------------------
  |  Branch (10311:16): [True: 5.69M, False: 2.65M]
  ------------------
10312|  5.69M|      out += s[i];
10313|  5.69M|    } else if (s[i] == '\\') {
  ------------------
  |  Branch (10313:16): [True: 334, False: 2.64M]
  ------------------
10314|    334|      i++;
10315|    334|    }
10316|  8.34M|  }
10317|    148|  return out;
10318|    148|}
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlPKcSF_E_clESF_SF_:
10349|  8.86M|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
10350|  8.86M|    std::string entry(b, e);
10351|  8.86M|    entry = trim_copy(entry);
10352|       |
10353|  8.86M|    AcceptEntry accept_entry;
10354|  8.86M|    accept_entry.order = order++;
10355|       |
10356|  8.86M|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
  ------------------
  |  Branch (10356:9): [True: 3.62k, False: 8.85M]
  ------------------
10357|  8.86M|                       accept_entry.media_type, accept_entry.quality)) {
10358|  3.62k|      has_invalid_entry = true;
10359|  3.62k|      return;
10360|  3.62k|    }
10361|       |
10362|       |    // Remove additional parameters from media type
10363|  8.85M|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
10364|       |
10365|       |    // Basic validation of media type format
10366|  8.85M|    if (accept_entry.media_type.empty()) {
  ------------------
  |  Branch (10366:9): [True: 0, False: 8.85M]
  ------------------
10367|      0|      has_invalid_entry = true;
10368|      0|      return;
10369|      0|    }
10370|       |
10371|       |    // Check for basic media type format (should contain '/' or be '*')
10372|  8.85M|    if (accept_entry.media_type != "*" &&
  ------------------
  |  Branch (10372:9): [True: 8.54M, False: 313k]
  ------------------
10373|  8.54M|        accept_entry.media_type.find('/') == std::string::npos) {
  ------------------
  |  Branch (10373:9): [True: 3.16k, False: 8.54M]
  ------------------
10374|  3.16k|      has_invalid_entry = true;
10375|  3.16k|      return;
10376|  3.16k|    }
10377|       |
10378|  8.85M|    entries.push_back(std::move(accept_entry));
10379|  8.85M|  });
_ZN7httplib6detail9trim_copyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6682|  17.7M|inline std::string trim_copy(const std::string &s) {
 6683|  17.7M|  auto r = trim(s.data(), s.data() + s.size(), 0, s.size());
 6684|  17.7M|  return s.substr(r.first, r.second - r.first);
 6685|  17.7M|}
_ZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERd:
 8652|  8.86M|                          double &quality) {
 8653|  8.86M|  quality = 1.0;
 8654|  8.86M|  token.clear();
 8655|       |
 8656|       |  // Split on first ';': left = token name, right = parameters
 8657|  8.86M|  const char *params_b = nullptr;
 8658|  8.86M|  std::size_t params_len = 0;
 8659|       |
 8660|  8.86M|  divide(
 8661|  8.86M|      b, static_cast<std::size_t>(e - b), ';',
 8662|  8.86M|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 8663|  8.86M|        auto r = trim(lb, lb + llen, 0, llen);
 8664|  8.86M|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
 8665|  8.86M|        params_b = rb;
 8666|  8.86M|        params_len = rlen;
 8667|  8.86M|      });
 8668|       |
 8669|  8.86M|  if (token.empty()) { return false; }
  ------------------
  |  Branch (8669:7): [True: 347, False: 8.86M]
  ------------------
 8670|  8.86M|  if (params_len == 0) { return true; }
  ------------------
  |  Branch (8670:7): [True: 8.80M, False: 56.6k]
  ------------------
 8671|       |
 8672|       |  // Scan parameters for q= (stops on first match)
 8673|  56.6k|  bool invalid = false;
 8674|  56.6k|  split_find(params_b, params_b + params_len, ';',
 8675|  56.6k|             (std::numeric_limits<size_t>::max)(),
 8676|  56.6k|             [&](const char *pb, const char *pe) -> bool {
 8677|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 8678|  56.6k|               auto len = static_cast<size_t>(pe - pb);
 8679|  56.6k|               if (len < 2) { return false; }
 8680|  56.6k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
 8681|  56.6k|                 return false;
 8682|  56.6k|               }
 8683|       |
 8684|       |               // Trim the value portion
 8685|  56.6k|               auto r = trim(pb, pe, 2, len);
 8686|  56.6k|               if (r.first >= r.second) {
 8687|  56.6k|                 invalid = true;
 8688|  56.6k|                 return true;
 8689|  56.6k|               }
 8690|       |
 8691|  56.6k|               double v = 0.0;
 8692|  56.6k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 8693|  56.6k|               if (res.ec != std::errc{} || res.ptr != pb + r.second ||
 8694|  56.6k|                   v < 0.0 || v > 1.0) {
 8695|  56.6k|                 invalid = true;
 8696|  56.6k|                 return true;
 8697|  56.6k|               }
 8698|  56.6k|               quality = v;
 8699|  56.6k|               return true;
 8700|  56.6k|             });
 8701|       |
 8702|  56.6k|  return !invalid;
 8703|  8.86M|}
_ZN7httplib6detail6divideEPKcmcNSt3__18functionIFvS2_mS2_mEEE:
 6713|  8.96M|           fn) {
 6714|  8.96M|  const auto it = std::find(data, data + size, d);
 6715|  8.96M|  const auto found = static_cast<std::size_t>(it != data + size);
 6716|  8.96M|  const auto lhs_data = data;
 6717|  8.96M|  const auto lhs_size = static_cast<std::size_t>(it - data);
 6718|  8.96M|  const auto rhs_data = it + found;
 6719|  8.96M|  const auto rhs_size = size - lhs_size - found;
 6720|       |
 6721|  8.96M|  fn(lhs_data, lhs_size, rhs_data, rhs_size);
 6722|  8.96M|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_mS2_mE_clES2_mS2_m:
 8662|  8.86M|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 8663|  8.86M|        auto r = trim(lb, lb + llen, 0, llen);
 8664|  8.86M|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
  ------------------
  |  Branch (8664:13): [True: 8.86M, False: 347]
  ------------------
 8665|  8.86M|        params_b = rb;
 8666|  8.86M|        params_len = rlen;
 8667|  8.86M|      });
_ZN7httplib6detail10split_findEPKcS2_cmNSt3__18functionIFbS2_S2_EEE:
 6812|  56.6k|                       std::function<bool(const char *, const char *)> fn) {
 6813|  56.6k|  size_t i = 0;
 6814|  56.6k|  size_t beg = 0;
 6815|  56.6k|  size_t count = 1;
 6816|       |
 6817|  21.9M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6817:10): [True: 21.9M, False: 0]
  |  Branch (6817:10): [True: 21.9M, False: 55.9k]
  ------------------
 6818|  21.9M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6818:9): [True: 10.4M, False: 11.4M]
  |  Branch (6818:22): [True: 10.4M, False: 0]
  ------------------
 6819|  10.4M|      auto r = trim(b, e, beg, i);
 6820|  10.4M|      if (r.first < r.second) {
  ------------------
  |  Branch (6820:11): [True: 722k, False: 9.75M]
  ------------------
 6821|   722k|        auto found = fn(&b[r.first], &b[r.second]);
 6822|   722k|        if (found) { return true; }
  ------------------
  |  Branch (6822:13): [True: 736, False: 721k]
  ------------------
 6823|   722k|      }
 6824|  10.4M|      beg = i + 1;
 6825|  10.4M|      count++;
 6826|  10.4M|    }
 6827|  21.9M|    i++;
 6828|  21.9M|  }
 6829|       |
 6830|  55.9k|  if (i) {
  ------------------
  |  Branch (6830:7): [True: 55.9k, False: 0]
  ------------------
 6831|  55.9k|    auto r = trim(b, e, beg, i);
 6832|  55.9k|    if (r.first < r.second) {
  ------------------
  |  Branch (6832:9): [True: 55.2k, False: 675]
  ------------------
 6833|  55.2k|      auto found = fn(&b[r.first], &b[r.second]);
 6834|  55.2k|      if (found) { return true; }
  ------------------
  |  Branch (6834:11): [True: 40.9k, False: 14.3k]
  ------------------
 6835|  55.2k|    }
 6836|  55.9k|  }
 6837|       |
 6838|  15.0k|  return false;
 6839|  55.9k|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_S2_E_clES2_S2_:
 8676|   777k|             [&](const char *pb, const char *pe) -> bool {
 8677|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 8678|   777k|               auto len = static_cast<size_t>(pe - pb);
 8679|   777k|               if (len < 2) { return false; }
  ------------------
  |  Branch (8679:20): [True: 726k, False: 51.3k]
  ------------------
 8680|  51.3k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
  ------------------
  |  Branch (8680:21): [True: 14.4k, False: 36.9k]
  |  Branch (8680:37): [True: 7.65k, False: 6.78k]
  |  Branch (8680:54): [True: 2.06k, False: 41.6k]
  ------------------
 8681|  9.71k|                 return false;
 8682|  9.71k|               }
 8683|       |
 8684|       |               // Trim the value portion
 8685|  41.6k|               auto r = trim(pb, pe, 2, len);
 8686|  41.6k|               if (r.first >= r.second) {
  ------------------
  |  Branch (8686:20): [True: 496, False: 41.1k]
  ------------------
 8687|    496|                 invalid = true;
 8688|    496|                 return true;
 8689|    496|               }
 8690|       |
 8691|  41.1k|               double v = 0.0;
 8692|  41.1k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 8693|  41.1k|               if (res.ec != std::errc{} || res.ptr != pb + r.second ||
  ------------------
  |  Branch (8693:20): [True: 695, False: 40.4k]
  |  Branch (8693:45): [True: 1.71k, False: 38.7k]
  ------------------
 8694|  38.7k|                   v < 0.0 || v > 1.0) {
  ------------------
  |  Branch (8694:20): [True: 0, False: 38.7k]
  |  Branch (8694:31): [True: 375, False: 38.3k]
  ------------------
 8695|  2.78k|                 invalid = true;
 8696|  2.78k|                 return true;
 8697|  2.78k|               }
 8698|  38.3k|               quality = v;
 8699|  38.3k|               return true;
 8700|  41.1k|             });
_ZN7httplib6detail10from_charsEPKcS2_Rd:
  851|  41.1k|                                            double &value) {
  852|  41.1k|  value = 0.0;
  853|  41.1k|  const char *p = first;
  854|       |
  855|       |  // Each 1eN is exactly representable, so a single final division by the
  856|       |  // matching entry yields a correctly-rounded result.
  857|  41.1k|  static const double powers_of_ten[] = {
  858|  41.1k|      1e0,  1e1,  1e2,  1e3,  1e4,  1e5,  1e6,  1e7,  1e8, 1e9,
  859|  41.1k|      1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18};
  860|  41.1k|  const int max_frac_digits =
  861|  41.1k|      static_cast<int>(sizeof(powers_of_ten) / sizeof(powers_of_ten[0])) - 1;
  862|       |
  863|       |  // Accumulate digits into a 64-bit integer and remember how many were
  864|       |  // fractional. Two independent caps keep this bounded and safe:
  865|       |  //   * accumulation saturates before mantissa could overflow uint64_t, and
  866|       |  //   * frac_digits is capped at max_frac_digits so it is always a valid index
  867|       |  //     into powers_of_ten (without this an input like "0.000...0" would never
  868|       |  //     grow mantissa, so the saturation cap alone would not bound it).
  869|       |  // Both caps only drop digits far beyond the precision a q-value needs; any
  870|       |  // value they would change is well outside [0, 1] and rejected by the caller.
  871|  41.1k|  uint64_t mantissa = 0;
  872|  41.1k|  int frac_digits = 0;
  873|  41.1k|  bool seen_digit = false;
  874|       |
  875|  41.1k|  const uint64_t limit = ((std::numeric_limits<uint64_t>::max)() - 9) / 10;
  876|  41.1k|  auto accumulate = [&](char c) {
  877|  41.1k|    if (mantissa <= limit) {
  878|  41.1k|      mantissa = mantissa * 10 + static_cast<uint64_t>(c - '0');
  879|  41.1k|      return true;
  880|  41.1k|    }
  881|  41.1k|    return false;
  882|  41.1k|  };
  883|       |
  884|  82.3k|  for (; p != last && is_ascii_digit(*p); ++p) {
  ------------------
  |  Branch (884:10): [True: 47.3k, False: 34.9k]
  |  Branch (884:23): [True: 41.2k, False: 6.17k]
  ------------------
  885|  41.2k|    seen_digit = true;
  886|  41.2k|    accumulate(*p);
  887|  41.2k|  }
  888|       |
  889|  41.1k|  if (p != last && *p == '.') {
  ------------------
  |  Branch (889:7): [True: 6.17k, False: 34.9k]
  |  Branch (889:20): [True: 4.39k, False: 1.78k]
  ------------------
  890|  4.39k|    ++p;
  891|  11.4k|    for (; p != last && is_ascii_digit(*p); ++p) {
  ------------------
  |  Branch (891:12): [True: 7.51k, False: 3.96k]
  |  Branch (891:25): [True: 7.08k, False: 428]
  ------------------
  892|  7.08k|      seen_digit = true;
  893|  7.08k|      if (frac_digits < max_frac_digits && accumulate(*p)) { ++frac_digits; }
  ------------------
  |  Branch (893:11): [True: 5.88k, False: 1.20k]
  |  Branch (893:44): [True: 5.64k, False: 235]
  ------------------
  894|  7.08k|    }
  895|  4.39k|  }
  896|       |
  897|  41.1k|  if (!seen_digit) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (897:7): [True: 695, False: 40.4k]
  ------------------
  898|       |
  899|  40.4k|  value = static_cast<double>(mantissa) / powers_of_ten[frac_digits];
  900|  40.4k|  return {p, std::errc{}};
  901|  41.1k|}
_ZZN7httplib6detail10from_charsEPKcS2_RdENKUlcE_clEc:
  876|  47.0k|  auto accumulate = [&](char c) {
  877|  47.0k|    if (mantissa <= limit) {
  ------------------
  |  Branch (877:9): [True: 46.3k, False: 739]
  ------------------
  878|  46.3k|      mantissa = mantissa * 10 + static_cast<uint64_t>(c - '0');
  879|  46.3k|      return true;
  880|  46.3k|    }
  881|    739|    return false;
  882|  47.0k|  };
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlRKZNS0_19parse_accept_headerES9_SD_E11AcceptEntrySG_E_clESG_SG_:
10386|   178M|            [](const AcceptEntry &a, const AcceptEntry &b) {
10387|   178M|              if (a.quality != b.quality) {
  ------------------
  |  Branch (10387:19): [True: 101k, False: 178M]
  ------------------
10388|   101k|                return a.quality > b.quality; // Higher quality first
10389|   101k|              }
10390|   178M|              return a.order < b.order; // Earlier order first for same quality
10391|   178M|            });
_ZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEE:
 8597|  8.85M|                   std::map<std::string, std::string> *params = nullptr) {
 8598|       |  // Extract type/subtype from Content-Type value (RFC 2045)
 8599|       |  // e.g. "application/json; charset=utf-8" -> "application/json"
 8600|  8.85M|  auto media_type = content_type;
 8601|  8.85M|  auto semicolon_pos = media_type.find(';');
 8602|  8.85M|  if (semicolon_pos != std::string::npos) {
  ------------------
  |  Branch (8602:7): [True: 260, False: 8.85M]
  ------------------
 8603|    260|    auto param_str = media_type.substr(semicolon_pos + 1);
 8604|    260|    media_type = media_type.substr(0, semicolon_pos);
 8605|       |
 8606|    260|    if (params) {
  ------------------
  |  Branch (8606:9): [True: 245, False: 15]
  ------------------
 8607|       |      // Parse parameters: key=value pairs separated by ';'
 8608|    245|      split_unquoted(param_str.data(), param_str.data() + param_str.size(), ';',
 8609|    245|                     [&](const char *b, const char *e) {
 8610|    245|                       std::string key;
 8611|    245|                       std::string val;
 8612|    245|                       divide_param_pair(b, e, key, val);
 8613|       |                       // Parameter names are case-insensitive (RFC 9110
 8614|       |                       // §5.6.6)
 8615|    245|                       if (!key.empty()) {
 8616|    245|                         params->emplace(case_ignore::to_lower(trim_copy(key)),
 8617|    245|                                         unquote_param(val));
 8618|    245|                       }
 8619|    245|                     });
 8620|    245|    }
 8621|    260|  }
 8622|       |
 8623|       |  // Trim whitespace from media type
 8624|  8.85M|  return trim_copy(media_type);
 8625|  8.85M|}
_ZN7httplib6detail14split_unquotedEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 6791|    961|                           std::function<void(const char *, const char *)> fn) {
 6792|    961|  return split_unquoted(b, e, d, (std::numeric_limits<size_t>::max)(),
 6793|    961|                        std::move(fn));
 6794|    961|}
_ZN7httplib6detail14split_unquotedEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 6762|    961|                           std::function<void(const char *, const char *)> fn) {
 6763|    961|  size_t i = 0;
 6764|    961|  size_t beg = 0;
 6765|    961|  size_t count = 1;
 6766|    961|  auto in_quotes = false;
 6767|       |
 6768|    961|  auto has = [&](size_t j) { return e ? (b + j < e) : (b[j] != '\0'); };
 6769|  39.9M|  while (has(i)) {
  ------------------
  |  Branch (6769:10): [True: 39.9M, False: 961]
  ------------------
 6770|  39.9M|    if (in_quotes && b[i] == '\\' && has(i + 1)) {
  ------------------
  |  Branch (6770:9): [True: 11.1M, False: 28.8M]
  |  Branch (6770:22): [True: 19.7k, False: 11.0M]
  |  Branch (6770:38): [True: 19.7k, False: 7]
  ------------------
 6771|       |      // A quoted-pair, whose second character does not end the string.
 6772|  19.7k|      i++;
 6773|  39.9M|    } else if (b[i] == '"') {
  ------------------
  |  Branch (6773:16): [True: 37.1k, False: 39.8M]
  ------------------
 6774|  37.1k|      in_quotes = !in_quotes;
 6775|  39.8M|    } else if (b[i] == d && !in_quotes && count < m) {
  ------------------
  |  Branch (6775:16): [True: 5.09M, False: 34.7M]
  |  Branch (6775:29): [True: 4.92M, False: 175k]
  |  Branch (6775:43): [True: 4.92M, False: 0]
  ------------------
 6776|  4.92M|      auto r = trim(b, e, beg, i);
 6777|  4.92M|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6777:11): [True: 400k, False: 4.52M]
  ------------------
 6778|  4.92M|      beg = i + 1;
 6779|  4.92M|      count++;
 6780|  4.92M|    }
 6781|  39.9M|    i++;
 6782|  39.9M|  }
 6783|       |
 6784|    961|  if (i) {
  ------------------
  |  Branch (6784:7): [True: 954, False: 7]
  ------------------
 6785|    954|    auto r = trim(b, e, beg, i);
 6786|    954|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6786:9): [True: 853, False: 101]
  ------------------
 6787|    954|  }
 6788|    961|}
_ZZN7httplib6detail14split_unquotedEPKcS2_cmNSt3__18functionIFvS2_S2_EEEENKUlmE_clEm:
 6768|  39.9M|  auto has = [&](size_t j) { return e ? (b + j < e) : (b[j] != '\0'); };
  ------------------
  |  Branch (6768:37): [True: 39.9M, False: 0]
  ------------------
_ZZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEEENKUlPKcSJ_E_clESJ_SJ_:
 8609|  5.02k|                     [&](const char *b, const char *e) {
 8610|  5.02k|                       std::string key;
 8611|  5.02k|                       std::string val;
 8612|  5.02k|                       divide_param_pair(b, e, key, val);
 8613|       |                       // Parameter names are case-insensitive (RFC 9110
 8614|       |                       // §5.6.6)
 8615|  5.02k|                       if (!key.empty()) {
  ------------------
  |  Branch (8615:28): [True: 4.63k, False: 383]
  ------------------
 8616|  4.63k|                         params->emplace(case_ignore::to_lower(trim_copy(key)),
 8617|  4.63k|                                         unquote_param(val));
 8618|  4.63k|                       }
 8619|  5.02k|                     });
_ZN7httplib6detail17divide_param_pairEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESA_:
 6800|  99.0k|                              std::string &val) {
 6801|  99.0k|  divide(
 6802|  99.0k|      b, static_cast<std::size_t>(e - b), '=',
 6803|  99.0k|      [&](const char *kb, std::size_t klen, const char *vb, std::size_t vlen) {
 6804|  99.0k|        const auto kr = trim(kb, kb + klen, 0, klen);
 6805|  99.0k|        key.assign(kb + kr.first, kb + kr.second);
 6806|  99.0k|        const auto vr = trim(vb, vb + vlen, 0, vlen);
 6807|  99.0k|        val.assign(vb + vr.first, vb + vr.second);
 6808|  99.0k|      });
 6809|  99.0k|}
_ZZN7httplib6detail17divide_param_pairEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESA_ENKUlS2_mS2_mE_clES2_mS2_m:
 6803|  99.0k|      [&](const char *kb, std::size_t klen, const char *vb, std::size_t vlen) {
 6804|  99.0k|        const auto kr = trim(kb, kb + klen, 0, klen);
 6805|  99.0k|        key.assign(kb + kr.first, kb + kr.second);
 6806|  99.0k|        const auto vr = trim(vb, vb + vlen, 0, vlen);
 6807|  99.0k|        val.assign(vb + vr.first, vb + vr.second);
 6808|  99.0k|      });
_ZN7httplib6detail11case_ignore8to_lowerERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
  710|  98.0k|inline std::string to_lower(const std::string &s) {
  711|  98.0k|  std::string result = s;
  712|  98.0k|  std::transform(
  713|  98.0k|      result.begin(), result.end(), result.begin(),
  714|  98.0k|      [](unsigned char c) { return static_cast<char>(to_lower(c)); });
  715|  98.0k|  return result;
  716|  98.0k|}
_ZZN7httplib6detail11case_ignore8to_lowerERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEENKUlhE_clEh:
  714|  27.9M|      [](unsigned char c) { return static_cast<char>(to_lower(c)); });
_ZN7httplib6detail13unquote_paramERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6697|  97.9k|inline std::string unquote_param(const std::string &s) {
 6698|  97.9k|  if (s.size() < 2 || s.front() != '"' || s.back() != '"') { return s; }
  ------------------
  |  Branch (6698:7): [True: 93.7k, False: 4.21k]
  |  Branch (6698:23): [True: 3.48k, False: 729]
  |  Branch (6698:43): [True: 357, False: 372]
  ------------------
 6699|    372|  std::string out;
 6700|  1.06M|  for (size_t i = 1; i + 1 < s.size(); i++) {
  ------------------
  |  Branch (6700:22): [True: 1.06M, False: 372]
  ------------------
 6701|  1.06M|    if (s[i] == '\\' && i + 2 < s.size() &&
  ------------------
  |  Branch (6701:9): [True: 21.8k, False: 1.04M]
  |  Branch (6701:25): [True: 21.8k, False: 4]
  ------------------
 6702|  21.8k|        (s[i + 1] == '"' || s[i + 1] == '\\')) {
  ------------------
  |  Branch (6702:10): [True: 1.46k, False: 20.3k]
  |  Branch (6702:29): [True: 6.32k, False: 14.0k]
  ------------------
 6703|  7.79k|      i++;
 6704|  7.79k|    }
 6705|  1.06M|    out += s[i];
 6706|  1.06M|  }
 6707|    372|  return out;
 6708|  97.9k|}
_ZN7httplib6detail24parse_multipart_boundaryERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERS7_:
10204|    210|                                     std::string &boundary) {
10205|    210|  std::map<std::string, std::string> params;
10206|    210|  extract_media_type(content_type, &params);
10207|    210|  auto it = params.find("boundary");
10208|    210|  if (it == params.end()) { return false; }
  ------------------
  |  Branch (10208:7): [True: 181, False: 29]
  ------------------
10209|     29|  boundary = it->second;
10210|       |  // RFC 2046 5.1.1 caps a boundary at 70 characters. The parser scans the body
10211|       |  // for "--" + boundary, so a body crafted to repeat that delimiter's leading
10212|       |  // bytes costs a nearly full comparison at nearly every position: the
10213|       |  // boundary's length multiplies the worst-case cost of scanning a body.
10214|     29|  return !boundary.empty() && boundary.size() <= 70;
  ------------------
  |  Branch (10214:10): [True: 28, False: 1]
  |  Branch (10214:31): [True: 14, False: 14]
  ------------------
10215|    210|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEEC2Ev:
 1299|    716|  insertion_ordered_multimap() = default;
_ZN7httplib6detail24parse_disposition_paramsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_26insertion_ordered_multimapIS7_NS1_8equal_toIS7_EEEE:
10217|    716|inline void parse_disposition_params(const std::string &s, Params &params) {
10218|    716|  std::set<std::string> cache;
10219|    716|  split_unquoted(
10220|    716|      s.data(), s.data() + s.size(), ';', [&](const char *b, const char *e) {
10221|    716|        std::string kv(b, e);
10222|    716|        if (cache.find(kv) != cache.end()) { return; }
10223|    716|        cache.insert(kv);
10224|       |
10225|    716|        std::string key;
10226|    716|        std::string val;
10227|    716|        divide_param_pair(b, e, key, val);
10228|       |
10229|       |        // Parameter names are case-insensitive (RFC 2045 §5.1)
10230|    716|        if (!key.empty()) {
10231|    716|          params.emplace(case_ignore::to_lower(trim_double_quotes_copy(key)),
10232|    716|                         unquote_param(val));
10233|    716|        }
10234|    716|      });
10235|    716|}
_ZZN7httplib6detail24parse_disposition_paramsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_26insertion_ordered_multimapIS7_NS1_8equal_toIS7_EEEEENKUlPKcSG_E_clESG_SG_:
10220|   396k|      s.data(), s.data() + s.size(), ';', [&](const char *b, const char *e) {
10221|   396k|        std::string kv(b, e);
10222|   396k|        if (cache.find(kv) != cache.end()) { return; }
  ------------------
  |  Branch (10222:13): [True: 302k, False: 93.9k]
  ------------------
10223|  93.9k|        cache.insert(kv);
10224|       |
10225|  93.9k|        std::string key;
10226|  93.9k|        std::string val;
10227|  93.9k|        divide_param_pair(b, e, key, val);
10228|       |
10229|       |        // Parameter names are case-insensitive (RFC 2045 §5.1)
10230|  93.9k|        if (!key.empty()) {
  ------------------
  |  Branch (10230:13): [True: 93.2k, False: 706]
  ------------------
10231|  93.2k|          params.emplace(case_ignore::to_lower(trim_double_quotes_copy(key)),
10232|  93.2k|                         unquote_param(val));
10233|  93.2k|        }
10234|  93.9k|      });
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE7emplaceIJS8_S8_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1328|  93.2k|  template <typename... Args> iterator emplace(Args &&...args) {
 1329|  93.2k|    entries_.emplace_back(std::forward<Args>(args)...);
 1330|  93.2k|    return make_iter(entries_.size() - 1, npos());
 1331|  93.2k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE9make_iterEmm:
 1437|  93.2k|  iterator make_iter(size_type idx, size_type key_idx) {
 1438|  93.2k|    return iterator(entries_.data(), idx, entries_.size(), key_idx);
 1439|  93.2k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE10iterator_tINS2_4pairIS8_S8_EEEC2EPSE_mmm:
 1283|  93.2k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE4nposEv:
 1203|  93.2k|  static size_type npos() { return static_cast<size_type>(-1); }
_ZN7httplib6detail23trim_double_quotes_copyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6687|  93.2k|inline std::string trim_double_quotes_copy(const std::string &s) {
 6688|  93.2k|  if (s.length() >= 2 && s.front() == '"' && s.back() == '"') {
  ------------------
  |  Branch (6688:7): [True: 80.4k, False: 12.8k]
  |  Branch (6688:26): [True: 1.02k, False: 79.3k]
  |  Branch (6688:46): [True: 274, False: 747]
  ------------------
 6689|    274|    return s.substr(1, s.size() - 2);
 6690|    274|  }
 6691|  93.0k|  return s;
 6692|  93.2k|}
_ZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5868|      3|inline time_t parse_http_date(const std::string &date_str) {
 5869|      3|  struct tm tm_buf;
 5870|       |
 5871|       |  // Create a classic locale object once for all parsing attempts
 5872|      3|  const std::locale classic_locale = std::locale::classic();
 5873|       |
 5874|       |  // Try to parse using std::get_time (C++11, cross-platform)
 5875|      3|  auto try_parse = [&](const char *fmt) -> bool {
 5876|      3|    std::istringstream ss(date_str);
 5877|      3|    ss.imbue(classic_locale);
 5878|       |
 5879|      3|    memset(&tm_buf, 0, sizeof(tm_buf));
 5880|      3|    ss >> std::get_time(&tm_buf, fmt);
 5881|       |
 5882|      3|    return !ss.fail();
 5883|      3|  };
 5884|       |
 5885|       |  // RFC 9110 preferred format (HTTP-date): "Sun, 06 Nov 1994 08:49:37 GMT"
 5886|      3|  if (!try_parse("%a, %d %b %Y %H:%M:%S")) {
  ------------------
  |  Branch (5886:7): [True: 2, False: 1]
  ------------------
 5887|       |    // RFC 850 format: "Sunday, 06-Nov-94 08:49:37 GMT"
 5888|      2|    if (!try_parse("%A, %d-%b-%y %H:%M:%S")) {
  ------------------
  |  Branch (5888:9): [True: 2, False: 0]
  ------------------
 5889|       |      // asctime format: "Sun Nov  6 08:49:37 1994"
 5890|      2|      if (!try_parse("%a %b %d %H:%M:%S %Y")) {
  ------------------
  |  Branch (5890:11): [True: 2, False: 0]
  ------------------
 5891|      2|        return static_cast<time_t>(-1);
 5892|      2|      }
 5893|      2|    }
 5894|      2|  }
 5895|       |
 5896|       |#ifdef _WIN32
 5897|       |  return _mkgmtime(&tm_buf);
 5898|       |#elif defined _AIX
 5899|       |  return mktime(&tm_buf);
 5900|       |#else
 5901|      1|  return timegm(&tm_buf);
 5902|      3|#endif
 5903|      3|}
_ZZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEENKUlPKcE_clESB_:
 5875|      7|  auto try_parse = [&](const char *fmt) -> bool {
 5876|      7|    std::istringstream ss(date_str);
 5877|      7|    ss.imbue(classic_locale);
 5878|       |
 5879|      7|    memset(&tm_buf, 0, sizeof(tm_buf));
 5880|      7|    ss >> std::get_time(&tm_buf, fmt);
 5881|       |
 5882|      7|    return !ss.fail();
 5883|      7|  };
_ZN7httplib6detail25can_compress_content_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8627|    176|inline bool can_compress_content_type(const std::string &content_type) {
 8628|       |  // Media types are case-insensitive (RFC 9110 §8.3.1)
 8629|    176|  auto mime_type = case_ignore::to_lower(extract_media_type(content_type));
 8630|       |
 8631|    176|  static const char *const compressible[] = {
 8632|    176|      "image/svg+xml",
 8633|    176|      "application/javascript",
 8634|    176|      "application/x-javascript",
 8635|    176|      "application/json",
 8636|    176|      "application/ld+json",
 8637|    176|      "application/xml",
 8638|    176|      "application/xhtml+xml",
 8639|    176|      "application/rss+xml",
 8640|    176|      "application/atom+xml",
 8641|    176|      "application/xslt+xml",
 8642|    176|      "application/protobuf",
 8643|    176|  };
 8644|       |
 8645|  1.90k|  for (auto type : compressible) {
  ------------------
  |  Branch (8645:18): [True: 1.90k, False: 172]
  ------------------
 8646|  1.90k|    if (mime_type == type) { return true; }
  ------------------
  |  Branch (8646:9): [True: 4, False: 1.90k]
  ------------------
 8647|  1.90k|  }
 8648|    172|  return mime_type != "text/event-stream" && !mime_type.rfind("text/", 0);
  ------------------
  |  Branch (8648:10): [True: 171, False: 1]
  |  Branch (8648:46): [True: 5, False: 166]
  ------------------
 8649|    176|}

LLVMFuzzerTestOneInput:
    7|  3.23k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    8|  3.23k|  if (size < 2) return 0;
  ------------------
  |  Branch (8:7): [True: 1, False: 3.23k]
  ------------------
    9|       |
   10|  3.23k|  uint8_t selector = data[0];
   11|  3.23k|  const char *payload = reinterpret_cast<const char *>(data + 1);
   12|  3.23k|  size_t payload_size = size - 1;
   13|  3.23k|  std::string input(payload, payload_size);
   14|       |
   15|  3.23k|  switch (selector % 7) {
  ------------------
  |  Branch (15:11): [True: 3.23k, False: 0]
  ------------------
   16|    507|  case 0: {
  ------------------
  |  Branch (16:3): [True: 507, False: 2.72k]
  ------------------
   17|       |    // parse_range_header
   18|    507|    httplib::Ranges ranges;
   19|    507|    httplib::detail::parse_range_header(input, ranges);
   20|    507|    break;
   21|      0|  }
   22|  1.57k|  case 1: {
  ------------------
  |  Branch (22:3): [True: 1.57k, False: 1.65k]
  ------------------
   23|       |    // parse_accept_header
   24|  1.57k|    std::vector<std::string> content_types;
   25|  1.57k|    httplib::detail::parse_accept_header(input, content_types);
   26|  1.57k|    break;
   27|      0|  }
   28|     43|  case 2: {
  ------------------
  |  Branch (28:3): [True: 43, False: 3.19k]
  ------------------
   29|       |    // extract_media_type with params
   30|     43|    std::map<std::string, std::string> params;
   31|     43|    httplib::detail::extract_media_type(input, &params);
   32|     43|    break;
   33|      0|  }
   34|    210|  case 3: {
  ------------------
  |  Branch (34:3): [True: 210, False: 3.02k]
  ------------------
   35|       |    // parse_multipart_boundary
   36|    210|    std::string boundary;
   37|    210|    httplib::detail::parse_multipart_boundary(input, boundary);
   38|    210|    break;
   39|      0|  }
   40|    716|  case 4: {
  ------------------
  |  Branch (40:3): [True: 716, False: 2.51k]
  ------------------
   41|       |    // parse_disposition_params
   42|    716|    httplib::Params params;
   43|    716|    httplib::detail::parse_disposition_params(input, params);
   44|    716|    break;
   45|      0|  }
   46|      3|  case 5: {
  ------------------
  |  Branch (46:3): [True: 3, False: 3.23k]
  ------------------
   47|       |    // parse_http_date
   48|      3|    httplib::detail::parse_http_date(input);
   49|      3|    break;
   50|      0|  }
   51|    176|  case 6: {
  ------------------
  |  Branch (51:3): [True: 176, False: 3.05k]
  ------------------
   52|       |    // can_compress_content_type
   53|    176|    httplib::detail::can_compress_content_type(input);
   54|    176|    break;
   55|      0|  }
   56|  3.23k|  }
   57|       |
   58|  3.23k|  return 0;
   59|  3.23k|}

