_ZN7httplib6StreamD2Ev:
 2047|  11.4k|  virtual ~Stream() = default;
_ZN7httplib6ServerC2Ev:
14661|      2|    : new_task_queue([] {
14662|      2|        return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT,
14663|      2|                              CPPHTTPLIB_THREAD_POOL_MAX_COUNT);
14664|      2|      }) {
14665|      2|#ifndef _WIN32
14666|      2|  signal(SIGPIPE, SIG_IGN);
14667|      2|#endif
14668|      2|  set_keep_alive_parking(CPPHTTPLIB_KEEPALIVE_PARKING);
  ------------------
  |  |   39|      2|#define CPPHTTPLIB_KEEPALIVE_PARKING false
  ------------------
14669|      2|}
_ZN7httplib6detail13write_headersERNS_6StreamERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9701|  5.71k|inline ssize_t write_headers(Stream &strm, const Headers &headers) {
 9702|  5.71k|  ssize_t write_len = 0;
 9703|  16.7k|  for (const auto &x : headers) {
  ------------------
  |  Branch (9703:22): [True: 16.7k, False: 5.71k]
  ------------------
 9704|  16.7k|    std::string s;
 9705|  16.7k|    s = x.first;
 9706|  16.7k|    s += ": ";
 9707|  16.7k|    s += x.second;
 9708|  16.7k|    s += "\r\n";
 9709|       |
 9710|  16.7k|    auto len = strm.write(s.data(), s.size());
 9711|  16.7k|    if (len < 0) { return len; }
  ------------------
  |  Branch (9711:9): [True: 0, False: 16.7k]
  ------------------
 9712|  16.7k|    write_len += len;
 9713|  16.7k|  }
 9714|  5.71k|  auto len = strm.write("\r\n");
 9715|  5.71k|  if (len < 0) { return len; }
  ------------------
  |  Branch (9715:7): [True: 0, False: 5.71k]
  ------------------
 9716|  5.71k|  write_len += len;
 9717|  5.71k|  return write_len;
 9718|  5.71k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1308|  7.31k|  const_iterator begin() const { return make_citer(0, npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10make_citerEmm:
 1441|   165k|  const_iterator make_citer(size_type idx, size_type key_idx) const {
 1442|   165k|    return const_iterator(entries_.data(), idx, entries_.size(), key_idx);
 1443|   165k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEC2EPSF_mmm:
 1283|   165k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4nposEv:
 1203|   378k|  static size_type npos() { return static_cast<size_type>(-1); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1309|   141k|  const_iterator end() const { return make_citer(entries_.size(), npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEneISF_EEbRKNSC_IT_EE:
 1274|   104k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1275|   104k|      return idx_ != rhs.idx_;
 1276|   104k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEdeEv:
 1231|  16.7k|    reference operator*() const { return data_[idx_]; }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEppEv:
 1234|  26.2k|    iterator_t &operator++() {
 1235|       |      // Saturating, so that advancing past the last entry of a key stays at
 1236|       |      // end() instead of running off the container.
 1237|  26.2k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1237:11): [True: 0, False: 26.2k]
  ------------------
 1238|  26.2k|      ++idx_;
 1239|  26.2k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1239:11): [True: 9.47k, False: 16.7k]
  ------------------
 1240|  12.3k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1240:16): [True: 10.5k, False: 1.85k]
  |  Branch (1240:32): [True: 2.88k, False: 7.62k]
  ------------------
 1241|  2.88k|          ++idx_;
 1242|  2.88k|        }
 1243|  9.47k|      }
 1244|  26.2k|      return *this;
 1245|  26.2k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEE7matchesEm:
 1285|  10.5k|    bool matches(size_type i) const {
 1286|  10.5k|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1287|  10.5k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10keys_equalERKS8_SD_:
 1205|   261k|  static bool keys_equal(const std::string &a, const std::string &b) {
 1206|   261k|    return KeyEqual()(a, b);
 1207|   261k|  }
_ZNK7httplib6detail11case_ignore8equal_toclERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_:
  735|   261k|  bool operator()(const std::string &a, const std::string &b) const {
  736|   261k|    return equal(a, b);
  737|   261k|  }
_ZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
  718|   275k|inline bool equal(const std::string &a, const std::string &b) {
  719|   275k|  return a.size() == b.size() &&
  ------------------
  |  Branch (719:10): [True: 35.4k, False: 240k]
  ------------------
  720|  35.4k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  ------------------
  |  Branch (720:10): [True: 32.2k, False: 3.13k]
  ------------------
  721|  35.4k|           return to_lower(ca) == to_lower(cb);
  722|  35.4k|         });
  723|   275k|}
_ZZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_ENKUlccE_clEcc:
  720|   277k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  721|   277k|           return to_lower(ca) == to_lower(cb);
  722|   277k|         });
_ZN7httplib6detail11case_ignore8to_lowerEi:
  686|   608k|inline unsigned char to_lower(int c) {
  687|   608k|  const static unsigned char table[256] = {
  688|   608k|      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  689|   608k|      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  690|   608k|      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  691|   608k|      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  692|   608k|      60,  61,  62,  63,  64,  97,  98,  99,  100, 101, 102, 103, 104, 105, 106,
  693|   608k|      107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
  694|   608k|      122, 91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  695|   608k|      105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  696|   608k|      120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  697|   608k|      135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  698|   608k|      150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  699|   608k|      165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  700|   608k|      180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 224, 225, 226,
  701|   608k|      227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
  702|   608k|      242, 243, 244, 245, 246, 215, 248, 249, 250, 251, 252, 253, 254, 223, 224,
  703|   608k|      225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  704|   608k|      240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  705|   608k|      255,
  706|   608k|  };
  707|   608k|  return table[(unsigned char)(char)c];
  708|   608k|}
_ZN7httplib6Stream5writeEPKc:
13262|  5.71k|inline ssize_t Stream::write(const char *ptr) {
13263|  5.71k|  return write(ptr, strlen(ptr));
13264|  5.71k|}
_ZN7httplib6Server22set_keep_alive_parkingEb:
15013|      2|inline Server &Server::set_keep_alive_parking(bool on) {
15014|       |  // Never destroyed once made: stop() may use it from another thread.
15015|      2|  if (on && !parking_) {
  ------------------
  |  Branch (15015:7): [True: 0, False: 2]
  |  Branch (15015:13): [True: 0, False: 0]
  ------------------
15016|      0|    auto poller = detail::make_poller();
15017|      0|    if (poller) {
  ------------------
  |  Branch (15017:9): [True: 0, False: 0]
  ------------------
15018|      0|      parking_.reset(new ParkingState());
15019|      0|      parking_->poller = std::move(poller);
15020|      0|    }
15021|      0|  }
15022|      2|  keep_alive_parking_ = on;
15023|      2|  return *this;
15024|      2|}
_ZN7httplib6Server15set_mount_pointERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_NS_6detail26insertion_ordered_multimapIS7_NSA_11case_ignore8equal_toEEE:
14812|      2|                                    const std::string &dir, Headers headers) {
14813|      2|  detail::FileStat stat(dir);
14814|      2|  if (stat.is_dir()) {
  ------------------
  |  Branch (14814:7): [True: 2, False: 0]
  ------------------
14815|      2|    std::string mnt = !mount_point.empty() ? mount_point : "/";
  ------------------
  |  Branch (14815:23): [True: 2, False: 0]
  ------------------
14816|      2|    if (!mnt.empty() && mnt[0] == '/') {
  ------------------
  |  Branch (14816:9): [True: 2, False: 0]
  |  Branch (14816:25): [True: 2, False: 0]
  ------------------
14817|       |      // Without the resolved directory, a file could not be checked to be
14818|       |      // inside it.
14819|      2|      std::string resolved_base;
14820|      2|      if (!detail::canonicalize_path(dir.c_str(), resolved_base)) {
  ------------------
  |  Branch (14820:11): [True: 0, False: 2]
  ------------------
14821|      0|        return false;
14822|      0|      }
14823|       |#if defined(_WIN32)
14824|       |      if (resolved_base.back() != '\\' && resolved_base.back() != '/') {
14825|       |        resolved_base += '\\';
14826|       |      }
14827|       |#else
14828|      2|      if (resolved_base.back() != '/') { resolved_base += '/'; }
  ------------------
  |  Branch (14828:11): [True: 2, False: 0]
  ------------------
14829|      2|#endif
14830|      2|      base_dirs_.push_back(
14831|      2|          {std::move(mnt), dir, std::move(resolved_base), std::move(headers)});
14832|      2|      return true;
14833|      2|    }
14834|      2|  }
14835|      0|  return false;
14836|      2|}
_ZN7httplib6detail8FileStatC2ERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
 6458|  1.60k|inline FileStat::FileStat(const std::string &path) {
 6459|       |#if defined(_WIN32)
 6460|       |  auto wpath = u8string_to_wstring(path.c_str());
 6461|       |  ret_ = _wstat(wpath.c_str(), &st_);
 6462|       |#else
 6463|  1.60k|  ret_ = stat(path.c_str(), &st_);
 6464|  1.60k|#endif
 6465|  1.60k|}
_ZNK7httplib6detail8FileStat6is_dirEv:
 6469|  1.60k|inline bool FileStat::is_dir() const {
 6470|  1.60k|  return ret_ >= 0 && S_ISDIR(st_.st_mode);
  ------------------
  |  Branch (6470:10): [True: 1.60k, False: 0]
  |  Branch (6470:23): [True: 8, False: 1.59k]
  ------------------
 6471|  1.60k|}
_ZN7httplib6detail17canonicalize_pathEPKcRNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
 6403|  1.68k|inline bool canonicalize_path(const char *path, std::string &resolved) {
 6404|       |#if defined(_WIN32)
 6405|       |  // Resolve junctions and symlinks, as realpath() does
 6406|       |  auto wpath = u8string_to_wstring(path);
 6407|       |  if (wpath.empty()) { return false; }
 6408|       |
 6409|       |  CREATEFILE2_EXTENDED_PARAMETERS params{};
 6410|       |  params.dwSize = sizeof(params);
 6411|       |  params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS; // Needed to open a directory
 6412|       |  auto h = ::CreateFile2(wpath.c_str(), 0,
 6413|       |                         FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
 6414|       |                         OPEN_EXISTING, &params);
 6415|       |  if (h == INVALID_HANDLE_VALUE) { return false; }
 6416|       |  auto guard = scope_exit([&]() { ::CloseHandle(h); });
 6417|       |
 6418|       |  std::wstring wbuf(MAX_PATH, L'\0');
 6419|       |  auto len = ::GetFinalPathNameByHandleW(
 6420|       |      h, &wbuf[0], static_cast<DWORD>(wbuf.size()), FILE_NAME_NORMALIZED);
 6421|       |  if (len >= wbuf.size()) {
 6422|       |    wbuf.resize(len);
 6423|       |    len = ::GetFinalPathNameByHandleW(
 6424|       |        h, &wbuf[0], static_cast<DWORD>(wbuf.size()), FILE_NAME_NORMALIZED);
 6425|       |  }
 6426|       |  if (len == 0 || len >= wbuf.size()) { return false; }
 6427|       |
 6428|       |  auto n = ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), static_cast<int>(len),
 6429|       |                                 nullptr, 0, nullptr, nullptr);
 6430|       |  if (n <= 0) { return false; }
 6431|       |  resolved.assign(static_cast<size_t>(n), '\0');
 6432|       |  ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), static_cast<int>(len),
 6433|       |                        &resolved[0], n, nullptr, nullptr);
 6434|       |#elif defined(PATH_MAX)
 6435|       |  char buf[PATH_MAX];
 6436|  1.68k|  if (realpath(path, buf) == nullptr) { return false; }
  ------------------
  |  Branch (6436:7): [True: 76, False: 1.60k]
  ------------------
 6437|  1.60k|  resolved = buf;
 6438|       |#else
 6439|       |  auto buf = realpath(path, nullptr);
 6440|       |  auto guard = scope_exit([&]() { std::free(buf); });
 6441|       |  if (buf == nullptr) { return false; }
 6442|       |  resolved = buf;
 6443|       |#endif
 6444|  1.60k|  return true;
 6445|  1.68k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEC2Ev:
 1299|  22.8k|  insertion_ordered_multimap() = default;
_ZN7httplib6Server15process_requestERNS_6StreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEiSB_ibRbRKNS3_8functionIFvRNS_7RequestEEEEPb:
16172|  5.72k|                        bool *websocket_upgraded) {
16173|  5.72k|  std::array<char, 2048> buf{};
16174|       |
16175|  5.72k|  detail::stream_line_reader line_reader(strm, buf.data(), buf.size());
16176|       |
16177|       |  // The read timeout bounds the request line and headers as a whole, so a
16178|       |  // client sending them a byte at a time cannot hold the worker any longer.
16179|  5.72k|  auto read_timeout_msec = read_timeout_sec_ * 1000 + read_timeout_usec_ / 1000;
16180|  5.72k|  strm.set_max_timeout(read_timeout_msec);
16181|       |
16182|       |  // Connection has been closed on client
16183|  5.72k|  if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (16183:7): [True: 4, False: 5.71k]
  ------------------
16184|       |
16185|       |  // RFC 9112 2.2: ignore an empty line received before the request-line. Some
16186|       |  // clients send an extra CRLF after a request body, which would otherwise be
16187|       |  // parsed as the next request on a persistent connection.
16188|  5.71k|  if (strcmp(line_reader.ptr(), "\r\n") == 0 && !line_reader.getline()) {
  ------------------
  |  Branch (16188:7): [True: 25, False: 5.69k]
  |  Branch (16188:49): [True: 1, False: 24]
  ------------------
16189|      1|    return false;
16190|      1|  }
16191|       |
16192|  5.71k|  Request req;
16193|  5.71k|  req.start_time_ = std::chrono::steady_clock::now();
16194|  5.71k|  req.remote_addr = remote_addr;
16195|  5.71k|  req.remote_port = remote_port;
16196|  5.71k|  req.local_addr = local_addr;
16197|  5.71k|  req.local_port = local_port;
16198|       |
16199|  5.71k|  Response res;
16200|  5.71k|  res.version = "HTTP/1.1";
16201|  5.71k|  res.headers = default_headers_;
16202|       |
16203|       |  // RFC 9112 §9.6: a server that sends the "close" connection option must
16204|       |  // close the connection after that response, whichever path wrote it (an
16205|       |  // error status, a handler, or a rejected request). Reading on would also
16206|       |  // parse whatever the client sent next on a connection it considers done.
16207|  5.71k|  auto honor_connection_close = detail::scope_exit([&] {
16208|  5.71k|    if (detail::has_header_token(res.headers, "Connection", "close")) {
16209|  5.71k|      connection_closed = true;
16210|  5.71k|    }
16211|  5.71k|  });
16212|       |
16213|       |  // Request line and headers. A rejected message leaves the rest of it (and
16214|       |  // any body) unread, so the connection cannot be reused: the leftover bytes
16215|       |  // would be parsed as the next request.
16216|  5.71k|  if (!parse_request_line(line_reader.ptr(), req)) {
  ------------------
  |  Branch (16216:7): [True: 310, False: 5.40k]
  ------------------
16217|    310|    connection_closed = true;
16218|    310|    res.status = StatusCode::BadRequest_400;
16219|    310|    output_error_log(Error::InvalidRequestLine, &req);
16220|    310|    return write_response(strm, close_connection, req, res);
16221|    310|  }
16222|       |
16223|       |  // Request headers
16224|  5.40k|  if (!detail::read_headers(strm, req.headers)) {
  ------------------
  |  Branch (16224:7): [True: 1.28k, False: 4.11k]
  ------------------
16225|  1.28k|    connection_closed = true;
16226|  1.28k|    res.status = StatusCode::BadRequest_400;
16227|  1.28k|    output_error_log(Error::InvalidHeaders, &req);
16228|  1.28k|    return write_response(strm, close_connection, req, res);
16229|  1.28k|  }
16230|  4.11k|  strm.set_max_timeout(0);
16231|       |
16232|       |  // RFC 9112 §6.3: Reject requests whose framing is invalid or ambiguous,
16233|       |  // which would otherwise let an intermediary and this parser disagree on
16234|       |  // where the body ends and enable request smuggling. Three cases: a
16235|       |  // Content-Length that is not a valid decimal length (e.g. "42, 42", "+42"
16236|       |  // or empty), which would otherwise be read as "no body"; a non-zero
16237|       |  // Content-Length alongside any Transfer-Encoding (Content-Length: 0 is
16238|       |  // tolerated for compatibility with existing clients); and a
16239|       |  // Transfer-Encoding whose final coding is not chunked, which leaves the body
16240|       |  // length undeterminable. None of them may fall through to the "no body"
16241|       |  // path, or the body bytes are parsed as the next request on a persistent
16242|       |  // connection.
16243|  4.11k|  auto is_invalid_content_length = false;
16244|  4.11k|  detail::get_header_value_u64(req.headers, "Content-Length", 0, 0,
16245|  4.11k|                               is_invalid_content_length);
16246|  4.11k|  if (is_invalid_content_length ||
  ------------------
  |  Branch (16246:7): [True: 85, False: 4.03k]
  |  Branch (16246:7): [True: 85, False: 4.03k]
  ------------------
16247|  4.03k|      detail::has_conflicting_content_length(req.headers) ||
  ------------------
  |  Branch (16247:7): [True: 0, False: 4.03k]
  ------------------
16248|  4.03k|      (req.has_header("Transfer-Encoding") &&
  ------------------
  |  Branch (16248:8): [True: 0, False: 4.03k]
  ------------------
16249|     85|       !detail::is_chunked_transfer_encoding(req.headers))) {
  ------------------
  |  Branch (16249:8): [True: 0, False: 0]
  ------------------
16250|     85|    connection_closed = true;
16251|     85|    res.status = StatusCode::BadRequest_400;
16252|     85|    return write_response(strm, close_connection, req, res);
16253|     85|  }
16254|       |
16255|       |  // RFC 9112 6.1: a lone "chunked" is the only transfer coding implemented
16256|  4.03k|  if (req.has_header("Transfer-Encoding") &&
  ------------------
  |  Branch (16256:7): [True: 0, False: 4.03k]
  |  Branch (16256:7): [True: 0, False: 4.03k]
  ------------------
16257|      0|      (req.get_header_value_count("Transfer-Encoding") != 1 ||
  ------------------
  |  Branch (16257:8): [True: 0, False: 0]
  ------------------
16258|      0|       !detail::case_ignore::equal(req.get_header_value("Transfer-Encoding"),
  ------------------
  |  Branch (16258:8): [True: 0, False: 0]
  ------------------
16259|      0|                                   "chunked"))) {
16260|      0|    connection_closed = true;
16261|      0|    res.status = StatusCode::NotImplemented_501;
16262|      0|    return write_response(strm, close_connection, req, res);
16263|      0|  }
16264|       |
16265|       |  // RFC 9112 §6.1: a Transfer-Encoding alongside a Content-Length, or in an
16266|       |  // HTTP/1.0 request, is honoured, but the connection closes after the
16267|       |  // response.
16268|  4.03k|  if (detail::has_faulty_transfer_encoding(req)) { connection_closed = true; }
  ------------------
  |  Branch (16268:7): [True: 0, False: 4.03k]
  ------------------
16269|       |
16270|       |  // RFC 9112 §3.2: Reject more than one Host field line, an invalid Host
16271|       |  // value, or none in HTTP/1.1, so that every recipient of the request sees
16272|       |  // the same authority.
16273|  4.03k|  auto host_count = req.get_header_value_count("Host");
16274|  4.03k|  if (host_count > 1 || (host_count == 0 && req.version == "HTTP/1.1") ||
  ------------------
  |  Branch (16274:7): [True: 7, False: 4.02k]
  |  Branch (16274:7): [True: 67, False: 3.96k]
  |  Branch (16274:26): [True: 3.36k, False: 666]
  |  Branch (16274:45): [True: 22, False: 3.33k]
  ------------------
16275|  4.00k|      !detail::fields::is_host(req.get_header_value("Host"))) {
  ------------------
  |  Branch (16275:7): [True: 38, False: 3.96k]
  ------------------
16276|     67|    connection_closed = true;
16277|     67|    res.status = StatusCode::BadRequest_400;
16278|     67|    output_error_log(Error::InvalidHeaders, &req);
16279|     67|    return write_response(strm, close_connection, req, res);
16280|     67|  }
16281|       |
16282|       |  // Check if the request URI doesn't exceed the limit
16283|  3.96k|  if (req.target.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
  ------------------
  |  |  123|  3.96k|#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
  ------------------
  |  Branch (16283:7): [True: 3, False: 3.96k]
  ------------------
16284|      3|    connection_closed = true;
16285|      3|    res.status = StatusCode::UriTooLong_414;
16286|      3|    output_error_log(Error::ExceedUriMaxLength, &req);
16287|      3|    return write_response(strm, close_connection, req, res);
16288|      3|  }
16289|       |
16290|  3.96k|  if (detail::has_header_token(req.headers, "Connection", "close")) {
  ------------------
  |  Branch (16290:7): [True: 2, False: 3.96k]
  ------------------
16291|      2|    connection_closed = true;
16292|      2|  }
16293|       |
16294|  3.96k|  if (req.version == "HTTP/1.0" &&
  ------------------
  |  Branch (16294:7): [True: 3.41k, False: 546]
  |  Branch (16294:7): [True: 3.41k, False: 546]
  ------------------
16295|  3.41k|      !detail::has_header_token(req.headers, "Connection", "keep-alive")) {
  ------------------
  |  Branch (16295:7): [True: 3.41k, False: 0]
  ------------------
16296|  3.41k|    connection_closed = true;
16297|  3.41k|  }
16298|       |
16299|       |  // Only honor X-Forwarded-For if the peer on the actual TCP connection is
16300|       |  // itself a trusted proxy. Otherwise any direct client could spoof
16301|       |  // remote_addr simply by sending an arbitrary X-Forwarded-For header.
16302|  3.96k|  if (detail::is_trusted_proxy(remote_addr, trusted_proxies_) &&
  ------------------
  |  Branch (16302:7): [True: 0, False: 3.96k]
  |  Branch (16302:7): [True: 0, False: 3.96k]
  ------------------
16303|      0|      req.has_header("X-Forwarded-For")) {
  ------------------
  |  Branch (16303:7): [True: 0, False: 0]
  ------------------
16304|       |    // Some proxies append the address they observed as a separate
16305|       |    // X-Forwarded-For field line instead of extending the one the client sent
16306|       |    // (e.g. HAProxy's "option forwardfor"), so the whole combined value has to
16307|       |    // be scanned. Reading only the first occurrence would hand back the
16308|       |    // client-supplied, and therefore forgeable, value.
16309|      0|    auto x_forwarded_for =
16310|      0|        detail::get_combined_header_value(req.headers, "X-Forwarded-For");
16311|      0|    auto derived = get_client_ip(x_forwarded_for, trusted_proxies_);
16312|      0|    req.remote_addr = derived.empty() ? remote_addr : derived;
  ------------------
  |  Branch (16312:23): [True: 0, False: 0]
  ------------------
16313|  3.96k|  } else {
16314|  3.96k|    req.remote_addr = remote_addr;
16315|  3.96k|  }
16316|  3.96k|  req.remote_port = remote_port;
16317|       |
16318|  3.96k|  req.local_addr = local_addr;
16319|  3.96k|  req.local_port = local_port;
16320|       |
16321|  3.96k|  if (req.has_header("Accept")) {
  ------------------
  |  Branch (16321:7): [True: 1.36k, False: 2.59k]
  ------------------
16322|  1.36k|    auto accept_header =
16323|  1.36k|        detail::get_combined_header_value(req.headers, "Accept");
16324|  1.36k|    if (!detail::parse_accept_header(accept_header, req.accept_content_types)) {
  ------------------
  |  Branch (16324:9): [True: 524, False: 842]
  ------------------
16325|    524|      connection_closed = true;
16326|    524|      res.status = StatusCode::BadRequest_400;
16327|    524|      output_error_log(Error::HTTPParsing, &req);
16328|    524|      return write_response(strm, close_connection, req, res);
16329|    524|    }
16330|  1.36k|  }
16331|       |
16332|       |  // RFC 9110 14.2: range handling is defined only for GET (and so for HEAD)
16333|  3.43k|  if ((req.method == "GET" || req.method == "HEAD") &&
  ------------------
  |  Branch (16333:7): [True: 1.23k, False: 2.20k]
  |  Branch (16333:8): [True: 3.21k, False: 229]
  |  Branch (16333:31): [True: 216, False: 13]
  ------------------
16334|  3.42k|      req.has_header("Range")) {
  ------------------
  |  Branch (16334:7): [True: 1.23k, False: 2.18k]
  ------------------
16335|  1.23k|    const auto &range_header_value = req.get_header_value("Range");
16336|       |    // RFC 9110 14.2: a range unit other than bytes must be ignored
16337|  1.23k|    auto unit = range_header_value.substr(0, range_header_value.find('='));
16338|  1.23k|    if (detail::case_ignore::equal(unit, "bytes") &&
  ------------------
  |  Branch (16338:9): [True: 1.19k, False: 45]
  ------------------
16339|  1.19k|        !detail::parse_range_header(range_header_value, req.ranges)) {
  ------------------
  |  Branch (16339:9): [True: 197, False: 995]
  ------------------
16340|    197|      connection_closed = true;
16341|    197|      res.status = StatusCode::RangeNotSatisfiable_416;
16342|    197|      output_error_log(Error::InvalidRangeHeader, &req);
16343|    197|      return write_response(strm, close_connection, req, res);
16344|    197|    }
16345|  1.23k|  }
16346|       |
16347|  3.24k|  if (setup_request) { setup_request(req); }
  ------------------
  |  Branch (16347:7): [True: 0, False: 3.24k]
  ------------------
16348|       |
16349|       |  // RFC 9110 10.1.1: Expect is a comma-separated list whose value is
16350|       |  // case-insensitive, and a 100-continue expectation in an HTTP/1.0 request
16351|       |  // must be ignored. An expectation we do not recognize is left alone; the
16352|       |  // 417 the section allows for one is a MAY, not a requirement.
16353|       |  //
16354|       |  // `100 Continue` itself is deferred until the body is actually read (see
16355|       |  // read_content_core), so a request rejected by a later handler never
16356|       |  // invites the client to send a body nobody will read.
16357|  3.24k|  if (req.version != "HTTP/1.0" &&
  ------------------
  |  Branch (16357:7): [True: 521, False: 2.72k]
  |  Branch (16357:7): [True: 0, False: 3.24k]
  ------------------
16358|    521|      detail::has_header_token(req.headers, "Expect", "100-continue")) {
  ------------------
  |  Branch (16358:7): [True: 0, False: 521]
  ------------------
16359|      0|    int status = StatusCode::Continue_100;
16360|      0|    if (expect_100_continue_handler_) {
  ------------------
  |  Branch (16360:9): [True: 0, False: 0]
  ------------------
16361|      0|      status = expect_100_continue_handler_(req, res);
16362|      0|    }
16363|      0|    if (status == StatusCode::Continue_100) {
  ------------------
  |  Branch (16363:9): [True: 0, False: 0]
  ------------------
16364|      0|      req.expect_100_continue_pending_ = true;
16365|      0|    } else {
16366|      0|      if (res.status == -1) { res.status = status; }
  ------------------
  |  Branch (16366:11): [True: 0, False: 0]
  ------------------
16367|      0|      connection_closed = true;
16368|      0|      return write_response(strm, true, req, res);
16369|      0|    }
16370|      0|  }
16371|       |
16372|       |  // Setup `is_connection_closed` method
16373|  3.24k|  auto sock = strm.socket();
16374|  3.24k|  req.is_connection_closed = [sock]() {
16375|  3.24k|    return !detail::is_socket_alive(sock);
16376|  3.24k|  };
16377|       |
16378|       |  // WebSocket upgrade
16379|       |  // Run pre_routing_handler_ and pre_request_handler_ before upgrading so
16380|       |  // that authentication and other middleware can reject the request with an
16381|       |  // HTTP response (e.g., 401) before the protocol switches.
16382|       |  // The response says so when this connection closes after it.
16383|  3.24k|  auto close_after_response = close_connection || connection_closed;
  ------------------
  |  Branch (16383:31): [True: 0, False: 3.24k]
  |  Branch (16383:51): [True: 2.72k, False: 521]
  ------------------
16384|       |
16385|       |  // An upgrade request has been through pre-routing before it reaches routing()
16386|  3.24k|  auto is_upgrade = detail::is_websocket_upgrade(req);
16387|  3.24k|  if (is_upgrade) {
  ------------------
  |  Branch (16387:7): [True: 0, False: 3.24k]
  ------------------
16388|       |    // A response given here leaves the body unread, and it would be parsed as
16389|       |    // the next request.
16390|      0|    auto close_if_answered =
16391|      0|        close_after_response || detail::has_framed_body(req);
  ------------------
  |  Branch (16391:9): [True: 0, False: 0]
  |  Branch (16391:33): [True: 0, False: 0]
  ------------------
16392|       |
16393|      0|    const WebSocketHandlerEntry *ws_route = nullptr;
16394|      0|    std::string selected_subprotocol;
16395|      0|    auto answer_before_upgrade = [&]() -> bool {
16396|      0|      if (pre_routing_handler_ &&
16397|      0|          pre_routing_handler_(req, res) == HandlerResponse::Handled) {
16398|      0|        return true;
16399|      0|      }
16400|      0|      for (const auto &entry : websocket_handlers_) {
16401|      0|        if (!entry.matcher->match(req)) { continue; }
16402|      0|        req.matched_route = entry.matcher->pattern();
16403|      0|        if (pre_request_handler_ &&
16404|      0|            pre_request_handler_(req, res) == HandlerResponse::Handled) {
16405|      0|          return true;
16406|      0|        }
16407|      0|        ws_route = &entry;
16408|       |
16409|      0|        if (entry.sub_protocol_selector) {
16410|      0|          auto protocol_header = detail::get_combined_header_value(
16411|      0|              req.headers, "Sec-WebSocket-Protocol");
16412|      0|          if (!protocol_header.empty()) {
16413|      0|            std::vector<std::string> protocols;
16414|      0|            detail::split(protocol_header.data(),
16415|      0|                          protocol_header.data() + protocol_header.size(), ',',
16416|      0|                          [&](const char *b, const char *e) {
16417|      0|                            protocols.emplace_back(b, e);
16418|      0|                          });
16419|      0|            selected_subprotocol = entry.sub_protocol_selector(protocols);
16420|       |
16421|       |            // Ignore a selection the client did not offer (RFC 6455 4.2.2)
16422|      0|            if (std::find(protocols.begin(), protocols.end(),
16423|      0|                          selected_subprotocol) == protocols.end()) {
16424|      0|              selected_subprotocol.clear();
16425|      0|            }
16426|      0|          }
16427|      0|        }
16428|      0|        return false;
16429|      0|      }
16430|      0|      return false;
16431|      0|    };
16432|       |
16433|      0|    auto answered = false;
16434|       |#ifdef CPPHTTPLIB_NO_EXCEPTIONS
16435|       |    answered = answer_before_upgrade();
16436|       |#else
16437|      0|    try {
16438|      0|      answered = answer_before_upgrade();
16439|      0|    } catch (...) {
16440|      0|      if (!handle_exception(req, res)) {
  ------------------
  |  Branch (16440:11): [True: 0, False: 0]
  ------------------
16441|      0|        return write_response(strm, close_if_answered, req, res);
16442|      0|      }
16443|      0|      answered = true;
16444|      0|    }
16445|      0|#endif
16446|      0|    if (answered) {
  ------------------
  |  Branch (16446:9): [True: 0, False: 0]
  ------------------
16447|      0|      if (res.status == -1) { res.status = StatusCode::OK_200; }
  ------------------
  |  Branch (16447:11): [True: 0, False: 0]
  ------------------
16448|      0|      return write_response_with_content(strm, close_if_answered, req, res);
16449|      0|    }
16450|       |
16451|      0|    if (ws_route) {
  ------------------
  |  Branch (16451:9): [True: 0, False: 0]
  ------------------
16452|      0|      auto client_key = req.get_header_value("Sec-WebSocket-Key");
16453|      0|      auto accept_key = detail::websocket_accept_key(client_key);
16454|       |
16455|       |      // Send 101 Switching Protocols
16456|      0|      std::string handshake_response = "HTTP/1.1 101 Switching Protocols\r\n"
16457|      0|                                       "Upgrade: websocket\r\n"
16458|      0|                                       "Connection: Upgrade\r\n"
16459|      0|                                       "Sec-WebSocket-Accept: " +
16460|      0|                                       accept_key + "\r\n";
16461|      0|      if (!selected_subprotocol.empty()) {
  ------------------
  |  Branch (16461:11): [True: 0, False: 0]
  ------------------
16462|      0|        if (!detail::fields::is_field_value(selected_subprotocol)) {
  ------------------
  |  Branch (16462:13): [True: 0, False: 0]
  ------------------
16463|      0|          return false;
16464|      0|        }
16465|      0|        handshake_response +=
16466|      0|            "Sec-WebSocket-Protocol: " + selected_subprotocol + "\r\n";
16467|      0|      }
16468|      0|      handshake_response += "\r\n";
16469|      0|      if (strm.write(handshake_response.data(), handshake_response.size()) <
  ------------------
  |  Branch (16469:11): [True: 0, False: 0]
  ------------------
16470|      0|          0) {
16471|      0|        return false;
16472|      0|      }
16473|       |
16474|      0|      connection_closed = true;
16475|      0|      if (websocket_upgraded) { *websocket_upgraded = true; }
  ------------------
  |  Branch (16475:11): [True: 0, False: 0]
  ------------------
16476|      0|      auto stopping = [this] { return is_stopping(); };
16477|      0|      ws::impl::Options options;
16478|      0|      options.ping_interval_sec = websocket_ping_interval_sec_;
16479|      0|      options.max_missed_pongs = websocket_max_missed_pongs_;
16480|      0|      options.max_message_length = websocket_max_message_length_;
16481|      0|      if (CPPHTTPLIB_WEBSOCKET_TCP_NODELAY) {
  ------------------
  |  |  303|      0|#define CPPHTTPLIB_WEBSOCKET_TCP_NODELAY true
  |  |  ------------------
  |  |  |  Branch (303:42): [True: 0, Folded]
  |  |  ------------------
  ------------------
16482|      0|        set_socket_opt(strm.socket(), IPPROTO_TCP, TCP_NODELAY, 1);
16483|      0|      }
16484|       |
16485|       |#ifdef CPPHTTPLIB_SSL_ENABLED
16486|       |      if (req.ssl) {
16487|       |        // wss: the heartbeat ping thread and the read path enter the same
16488|       |        // TLS session from different threads. Hand the WebSocket a stream
16489|       |        // that serializes every TLS call, so the shared SSLSocketStream on
16490|       |        // the plain HTTP/HTTPS paths stays untouched.
16491|       |        auto ws_strm = std::unique_ptr<Stream>(new detail::WebSocketSSLStream(
16492|       |            strm.socket(), const_cast<tls::session_t>(req.ssl),
16493|       |            CPPHTTPLIB_WEBSOCKET_SERVER_READ_TIMEOUT_SECOND, 0,
16494|       |            write_timeout_sec_, write_timeout_usec_));
16495|       |        ws::WebSocket ws(std::move(ws_strm), req, true, options, stopping);
16496|       |        ws_route->handler(req, ws);
16497|       |        return true;
16498|       |      }
16499|       |#endif
16500|       |      // Use WebSocket-specific read timeout instead of HTTP timeout
16501|      0|      strm.set_read_timeout(CPPHTTPLIB_WEBSOCKET_SERVER_READ_TIMEOUT_SECOND, 0);
  ------------------
  |  |  284|      0|#define CPPHTTPLIB_WEBSOCKET_SERVER_READ_TIMEOUT_SECOND 300
  ------------------
16502|      0|      ws::WebSocket ws(strm, req, true, options, stopping);
16503|      0|      ws_route->handler(req, ws);
16504|      0|      return true;
16505|      0|    }
16506|       |    // No WebSocket route: route it as a plain HTTP request
16507|      0|  }
16508|       |
16509|       |  // Routing
16510|  3.24k|  auto routed = false;
16511|       |#ifdef CPPHTTPLIB_NO_EXCEPTIONS
16512|       |  routed = routing(req, res, strm, is_upgrade);
16513|       |#else
16514|  3.24k|  try {
16515|  3.24k|    routed = routing(req, res, strm, is_upgrade);
16516|  3.24k|  } catch (...) { routed = handle_exception(req, res); }
16517|  3.24k|#endif
16518|  3.24k|  auto ret = false;
16519|  3.24k|  if (routed) {
  ------------------
  |  Branch (16519:7): [True: 1.60k, False: 1.63k]
  ------------------
16520|  1.60k|    if (res.status == -1) {
  ------------------
  |  Branch (16520:9): [True: 1.54k, False: 56]
  ------------------
16521|  1.54k|      res.status = req.ranges.empty() ? StatusCode::OK_200
  ------------------
  |  Branch (16521:20): [True: 935, False: 612]
  ------------------
16522|  1.54k|                                      : StatusCode::PartialContent_206;
16523|  1.54k|    }
16524|       |
16525|       |    // Before the Range checks below, so they see the body's own length.
16526|  1.60k|    detail::prefer_assigned_body(res);
16527|       |
16528|       |    // Serve file content by using a content provider
16529|  1.60k|    auto file_open_error = false;
16530|  1.60k|    if (!res.file_content_path_.empty()) {
  ------------------
  |  Branch (16530:9): [True: 0, False: 1.60k]
  ------------------
16531|      0|      const auto &path = res.file_content_path_;
16532|      0|      auto mm = std::make_shared<detail::mmap>(path.c_str());
16533|      0|      if (!mm->is_open()) {
  ------------------
  |  Branch (16533:11): [True: 0, False: 0]
  ------------------
16534|      0|        res.status = StatusCode::NotFound_404;
16535|      0|        output_error_log(Error::OpenFile, &req);
16536|      0|        file_open_error = true;
16537|      0|      } else {
16538|      0|        auto content_type = res.file_content_content_type_;
16539|      0|        if (content_type.empty()) {
  ------------------
  |  Branch (16539:13): [True: 0, False: 0]
  ------------------
16540|       |          // One the handler set after set_file_content()
16541|      0|          content_type = res.get_header_value("Content-Type");
16542|      0|        }
16543|      0|        if (content_type.empty()) {
  ------------------
  |  Branch (16543:13): [True: 0, False: 0]
  ------------------
16544|      0|          content_type = detail::find_content_type(
16545|      0|              path, file_extension_and_mimetype_map_, default_file_mimetype_);
16546|      0|        }
16547|       |
16548|      0|        detail::set_file_content_provider(
16549|      0|            res, mm, content_type,
16550|      0|            static_file_encoding(req, res, content_type, mm->size()));
16551|      0|      }
16552|      0|    }
16553|       |
16554|  1.60k|    if (file_open_error) {
  ------------------
  |  Branch (16554:9): [True: 0, False: 1.60k]
  ------------------
16555|      0|      ret = write_response(strm, close_after_response, req, res);
16556|  1.60k|    } else if (detail::range_error(req, res)) {
  ------------------
  |  Branch (16556:16): [True: 165, False: 1.43k]
  ------------------
16557|    165|      detail::clear_content(res);
16558|    165|      res.status = StatusCode::RangeNotSatisfiable_416;
16559|    165|      ret = write_response(strm, close_after_response, req, res);
16560|  1.43k|    } else {
16561|  1.43k|      ret = write_response_with_content(strm, close_after_response, req, res);
16562|  1.43k|    }
16563|  1.63k|  } else {
16564|  1.63k|    if (res.status == -1) { res.status = StatusCode::NotFound_404; }
  ------------------
  |  Branch (16564:9): [True: 1.63k, False: 1]
  ------------------
16565|  1.63k|    ret = write_response(strm, close_after_response, req, res);
16566|  1.63k|  }
16567|       |
16568|       |  // Drain any unconsumed framed body to prevent request smuggling on
16569|       |  // keep-alive. Without framing there is no body to drain — reading would
16570|       |  // consume the next request (issue #2450). If the response has committed the
16571|       |  // connection to close, there is no next request to protect. A body read in
16572|       |  // part cannot be drained from where it stopped, so the connection closes,
16573|       |  // as it does when the body is longer than the drain limit or does not
16574|       |  // arrive within the read timeout.
16575|  3.24k|  if (!req.body_consumed_ && detail::has_framed_body(req) &&
  ------------------
  |  Branch (16575:7): [True: 3.24k, False: 0]
  |  Branch (16575:7): [True: 356, False: 2.88k]
  |  Branch (16575:30): [True: 530, False: 2.71k]
  ------------------
16576|    530|      !detail::has_header_token(res.headers, "Connection", "close")) {
  ------------------
  |  Branch (16576:7): [True: 356, False: 174]
  ------------------
16577|    356|    strm.set_max_timeout(read_timeout_msec);
16578|    356|    int dummy_status;
16579|    356|    if (req.body_read_started_ ||
  ------------------
  |  Branch (16579:9): [True: 0, False: 356]
  |  Branch (16579:9): [True: 348, False: 8]
  ------------------
16580|    356|        !detail::read_content(
  ------------------
  |  Branch (16580:9): [True: 348, False: 8]
  ------------------
16581|    356|            strm, req, CPPHTTPLIB_UNREAD_PAYLOAD_MAX_LENGTH, dummy_status,
  ------------------
  |  |  153|    356|#define CPPHTTPLIB_UNREAD_PAYLOAD_MAX_LENGTH (256 * 1024) // 256KB
  ------------------
16582|    356|            nullptr, [](const char *, size_t, size_t, size_t) { return true; },
16583|    356|            false)) {
16584|    348|      connection_closed = true;
16585|    348|    }
16586|    356|  }
16587|       |
16588|  3.24k|  return ret;
16589|  3.24k|}
_ZN7httplib6detail18stream_line_readerC2ERNS_6StreamEPcm:
 6849|  11.1k|    : strm_(strm), fixed_buffer_(fixed_buffer),
 6850|  11.1k|      fixed_buffer_size_(fixed_buffer_size) {}
_ZN7httplib6detail18stream_line_reader7getlineEv:
 6873|  27.2k|inline bool stream_line_reader::getline() {
 6874|  27.2k|  fixed_buffer_used_size_ = 0;
 6875|  27.2k|  growable_buffer_.clear();
 6876|       |
 6877|  27.2k|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6878|  27.2k|  char prev_byte = 0;
 6879|  27.2k|#endif
 6880|       |
 6881|  44.2k|  for (size_t i = 0;; i++) {
 6882|       |    // Fast path: whatever the stream has already buffered can be scanned for
 6883|       |    // the terminator in one pass. Asking for a byte at a time costs a virtual
 6884|       |    // call, a bounds check and a one-byte copy per character of the request.
 6885|  44.2k|    size_t buffered_size = 0;
 6886|  44.2k|    if (auto buffered = strm_.buffered_data(buffered_size)) {
  ------------------
  |  Branch (6886:14): [True: 31.7k, False: 12.4k]
  ------------------
 6887|  31.7k|      auto take = buffered_size;
 6888|  31.7k|      auto terminated = false;
 6889|       |
 6890|   109k|      for (size_t at = 0; at < buffered_size;) {
  ------------------
  |  Branch (6890:27): [True: 109k, False: 89]
  ------------------
 6891|   109k|        auto nl = static_cast<const char *>(
 6892|   109k|            memchr(buffered + at, '\n', buffered_size - at));
 6893|   109k|        if (!nl) { break; }
  ------------------
  |  Branch (6893:13): [True: 5.70k, False: 104k]
  ------------------
 6894|   104k|        auto pos = static_cast<size_t>(nl - buffered);
 6895|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6896|       |        take = pos + 1;
 6897|       |        terminated = true;
 6898|       |        break;
 6899|       |#else
 6900|       |        // A bare LF does not end the line; keep looking for CRLF. The CR may
 6901|       |        // be the last byte of an earlier chunk, hence prev_byte.
 6902|   104k|        if ((pos > 0 ? buffered[pos - 1] : prev_byte) == '\r') {
  ------------------
  |  Branch (6902:13): [True: 25.9k, False: 78.0k]
  |  Branch (6902:14): [True: 103k, False: 104]
  ------------------
 6903|  25.9k|          take = pos + 1;
 6904|  25.9k|          terminated = true;
 6905|  25.9k|          break;
 6906|  25.9k|        }
 6907|  78.0k|        at = pos + 1;
 6908|  78.0k|#endif
 6909|  78.0k|      }
 6910|       |
 6911|  31.7k|      if (size() + take > CPPHTTPLIB_MAX_LINE_LENGTH) { return false; }
  ------------------
  |  |  238|  31.7k|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6911:11): [True: 3, False: 31.7k]
  ------------------
 6912|  31.7k|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6913|  31.7k|      prev_byte = buffered[take - 1];
 6914|  31.7k|#endif
 6915|  31.7k|      append(buffered, take);
 6916|  31.7k|      strm_.consume_buffered(take);
 6917|  31.7k|      i += take;
 6918|  31.7k|      if (terminated) { return true; }
  ------------------
  |  Branch (6918:11): [True: 25.9k, False: 5.79k]
  ------------------
 6919|  5.79k|      continue;
 6920|  31.7k|    }
 6921|       |
 6922|  12.4k|    if (size() >= CPPHTTPLIB_MAX_LINE_LENGTH) {
  ------------------
  |  |  238|  12.4k|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6922:9): [True: 1, False: 12.4k]
  ------------------
 6923|       |      // Treat exceptionally long lines as an error to
 6924|       |      // prevent infinite loops/memory exhaustion
 6925|      1|      return false;
 6926|      1|    }
 6927|  12.4k|    char byte;
 6928|  12.4k|    auto n = strm_.read(&byte, 1);
 6929|       |
 6930|  12.4k|    if (n < 0) {
  ------------------
  |  Branch (6930:9): [True: 0, False: 12.4k]
  ------------------
 6931|      0|      return false;
 6932|  12.4k|    } else if (n == 0) {
  ------------------
  |  Branch (6932:16): [True: 1.24k, False: 11.2k]
  ------------------
 6933|  1.24k|      if (i == 0) {
  ------------------
  |  Branch (6933:11): [True: 954, False: 290]
  ------------------
 6934|    954|        return false;
 6935|    954|      } else {
 6936|    290|        break;
 6937|    290|      }
 6938|  1.24k|    }
 6939|       |
 6940|  11.2k|    append(byte);
 6941|       |
 6942|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6943|       |    if (byte == '\n') { break; }
 6944|       |#else
 6945|  11.2k|    if (prev_byte == '\r' && byte == '\n') { break; }
  ------------------
  |  Branch (6945:9): [True: 41, False: 11.1k]
  |  Branch (6945:30): [True: 22, False: 19]
  ------------------
 6946|  11.2k|    prev_byte = byte;
 6947|  11.2k|#endif
 6948|  11.2k|  }
 6949|       |
 6950|    312|  return true;
 6951|  27.2k|}
_ZNK7httplib6detail18stream_line_reader4sizeEv:
 6860|   137k|inline size_t stream_line_reader::size() const {
 6861|   137k|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6861:7): [True: 110k, False: 27.0k]
  ------------------
 6862|   110k|    return fixed_buffer_used_size_;
 6863|   110k|  } else {
 6864|  27.0k|    return growable_buffer_.size();
 6865|  27.0k|  }
 6866|   137k|}
_ZN7httplib6detail18stream_line_reader6appendEPKcm:
 6955|  42.9k|inline void stream_line_reader::append(const char *data, size_t size) {
 6956|       |  // Once the line has outgrown the fixed buffer everything must keep going to
 6957|       |  // the growable one, even if a later chunk would have fit. Without the
 6958|       |  // emptiness check a short append after a long one would land in the fixed
 6959|       |  // buffer, which ptr() and size() no longer look at, and be lost.
 6960|  42.9k|  if (growable_buffer_.empty() &&
  ------------------
  |  Branch (6960:7): [True: 36.8k, False: 6.13k]
  ------------------
 6961|  36.8k|      fixed_buffer_used_size_ + size < fixed_buffer_size_) {
  ------------------
  |  Branch (6961:7): [True: 32.4k, False: 4.35k]
  ------------------
 6962|  32.4k|    memcpy(fixed_buffer_ + fixed_buffer_used_size_, data, size);
 6963|  32.4k|    fixed_buffer_used_size_ += size;
 6964|  32.4k|    fixed_buffer_[fixed_buffer_used_size_] = '\0';
 6965|  32.4k|  } else {
 6966|       |    // Unlike the per-character overload, this can be the very first append of
 6967|       |    // the line, so the fixed buffer may hold nothing and carry no terminator
 6968|       |    // yet. assign() takes an explicit length and does not need one.
 6969|  10.4k|    if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6969:9): [True: 4.35k, False: 6.13k]
  ------------------
 6970|  4.35k|      growable_buffer_.assign(fixed_buffer_, fixed_buffer_used_size_);
 6971|  4.35k|    }
 6972|  10.4k|    growable_buffer_.append(data, size);
 6973|  10.4k|  }
 6974|  42.9k|}
_ZN7httplib6detail18stream_line_reader6appendEc:
 6953|  11.2k|inline void stream_line_reader::append(char c) { append(&c, 1); }
_ZNK7httplib6detail18stream_line_reader3ptrEv:
 6852|  64.2k|inline const char *stream_line_reader::ptr() const {
 6853|  64.2k|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6853:7): [True: 51.4k, False: 12.8k]
  ------------------
 6854|  51.4k|    return fixed_buffer_;
 6855|  51.4k|  } else {
 6856|  12.8k|    return growable_buffer_.data();
 6857|  12.8k|  }
 6858|  64.2k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEEC2Ev:
 1299|  5.71k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_9FormFieldENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1299|  5.71k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_8FormDataENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1299|  5.71k|  insertion_ordered_multimap() = default;
_ZN7httplib8ResponseC2Ev:
 1969|  5.71k|  Response() = default;
_ZN7httplib8UserDataC2Ev:
 1495|  5.71k|  UserData() = default;
_ZZN7httplib6Server15process_requestERNS_6StreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEiSB_ibRbRKNS3_8functionIFvRNS_7RequestEEEEPbENKUlvE_clEv:
16207|  5.71k|  auto honor_connection_close = detail::scope_exit([&] {
16208|  5.71k|    if (detail::has_header_token(res.headers, "Connection", "close")) {
  ------------------
  |  Branch (16208:9): [True: 5.31k, False: 403]
  ------------------
16209|  5.31k|      connection_closed = true;
16210|  5.31k|    }
16211|  5.71k|  });
_ZN7httplib6detail10scope_exitC2EONSt3__18functionIFvvEEE:
  763|  5.71k|      : exit_function(std::move(f)), execute_on_destruction{true} {}
_ZNK7httplib6Server18parse_request_lineEPKcRNS_7RequestE:
15116|  5.71k|inline bool Server::parse_request_line(const char *s, Request &req) const {
15117|  5.71k|  auto len = strlen(s);
15118|  5.71k|  if (len < 2 || s[len - 2] != '\r' || s[len - 1] != '\n') { return false; }
  ------------------
  |  Branch (15118:7): [True: 7, False: 5.71k]
  |  Branch (15118:18): [True: 75, False: 5.63k]
  |  Branch (15118:40): [True: 18, False: 5.61k]
  ------------------
15119|  5.61k|  len -= 2;
15120|       |
15121|  5.61k|  {
15122|       |    // RFC 9112 §3: exactly one SP between the method, the target and the
15123|       |    // version. Taking other whitespace as a separator too lets recipients
15124|       |    // that parse more strictly see a different request.
15125|  5.61k|    auto end = s + len;
15126|  5.61k|    if (std::count(s, end, ' ') != 2) { return false; }
  ------------------
  |  Branch (15126:9): [True: 51, False: 5.56k]
  ------------------
15127|  5.56k|    auto sp1 = std::find(s, end, ' ');
15128|  5.56k|    auto sp2 = std::find(sp1 + 1, end, ' ');
15129|  5.56k|    if (sp1 == s || sp2 == sp1 + 1 || sp2 + 1 == end) { return false; }
  ------------------
  |  Branch (15129:9): [True: 1, False: 5.56k]
  |  Branch (15129:21): [True: 1, False: 5.56k]
  |  Branch (15129:39): [True: 1, False: 5.56k]
  ------------------
15130|  5.56k|    req.method.assign(s, sp1);
15131|  5.56k|    req.target.assign(sp1 + 1, sp2);
15132|  5.56k|    req.version.assign(sp2 + 1, end);
15133|  5.56k|  }
15134|       |
15135|       |  // A method outside the built-in set is accepted only when a handler has been
15136|       |  // registered for it with CustomRoute().
15137|      0|  const auto &methods = builtin_methods();
15138|       |
15139|  5.56k|  if (methods.find(req.method) == methods.end() &&
  ------------------
  |  Branch (15139:7): [True: 96, False: 5.46k]
  |  Branch (15139:7): [True: 96, False: 5.46k]
  ------------------
15140|     96|      !find_custom_entry(req.method)) {
  ------------------
  |  Branch (15140:7): [True: 96, False: 0]
  ------------------
15141|     96|    output_error_log(Error::InvalidHTTPMethod, &req);
15142|     96|    return false;
15143|     96|  }
15144|       |
15145|  5.46k|  if (req.version != "HTTP/1.1" && req.version != "HTTP/1.0") {
  ------------------
  |  Branch (15145:7): [True: 4.16k, False: 1.30k]
  |  Branch (15145:36): [True: 35, False: 4.13k]
  ------------------
15146|     35|    output_error_log(Error::InvalidHTTPVersion, &req);
15147|     35|    return false;
15148|     35|  }
15149|       |
15150|       |  // A request-target has no fragment (RFC 9112 §3.2), and one stripped here
15151|       |  // would leave this server routing a different path than a cache or a
15152|       |  // filter in front of it sees.
15153|  5.43k|  if (!detail::fields::is_request_target(req.target) ||
  ------------------
  |  Branch (15153:7): [True: 8, False: 5.42k]
  ------------------
15154|  5.42k|      req.target.find('#') != std::string::npos) {
  ------------------
  |  Branch (15154:7): [True: 17, False: 5.40k]
  ------------------
15155|     25|    return false;
15156|     25|  }
15157|       |
15158|  5.40k|  {
15159|  5.40k|    detail::divide(req.target, '?',
15160|  5.40k|                   [&](const char *lhs_data, std::size_t lhs_size,
15161|  5.40k|                       const char *rhs_data, std::size_t rhs_size) {
15162|  5.40k|                     req.path =
15163|  5.40k|                         decode_path_component(std::string(lhs_data, lhs_size));
15164|  5.40k|                     detail::parse_query_text(rhs_data, rhs_size, req.params);
15165|  5.40k|                   });
15166|  5.40k|  }
15167|       |
15168|  5.40k|  return true;
15169|  5.43k|}
_ZN7httplib6Server15builtin_methodsEv:
14740|  5.56k|inline const std::set<std::string> &Server::builtin_methods() {
14741|  5.56k|  thread_local const std::set<std::string> methods{
14742|  5.56k|      "GET",     "HEAD",    "POST",  "PUT",   "DELETE",
14743|  5.56k|      "CONNECT", "OPTIONS", "TRACE", "PATCH", "PRI"};
14744|  5.56k|  return methods;
14745|  5.56k|}
_ZNK7httplib6Server17find_custom_entryERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
14782|  1.73k|Server::find_custom_entry(const std::string &method) const {
14783|       |  // find() alone would be correct here. The empty() check is what keeps the
14784|       |  // per-request cost off servers that never call CustomRoute(), which is the
14785|       |  // overwhelmingly common case; keep it rather than walking into the tree.
14786|  1.73k|  if (custom_handlers_.empty()) { return nullptr; }
  ------------------
  |  Branch (14786:7): [True: 1.73k, False: 0]
  ------------------
14787|      0|  auto it = custom_handlers_.find(method);
14788|      0|  return it == custom_handlers_.end() ? nullptr : &it->second;
  ------------------
  |  Branch (14788:10): [True: 0, False: 0]
  ------------------
14789|  1.73k|}
_ZN7httplib6detail6fields17is_request_targetERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11311|  5.43k|inline bool is_request_target(const std::string &s) {
11312|  5.43k|  return std::all_of(s.begin(), s.end(), is_field_vchar);
11313|  5.43k|}
_ZN7httplib6detail6fields14is_field_vcharEc:
11276|  23.0M|inline bool is_field_vchar(char c) { return is_vchar(c) || is_obs_text(c); }
  ------------------
  |  Branch (11276:45): [True: 21.5M, False: 1.50M]
  |  Branch (11276:60): [True: 1.50M, False: 55]
  ------------------
_ZN7httplib6detail6fields8is_vcharEc:
11272|  23.0M|inline bool is_vchar(char c) { return c >= 33 && c <= 126; }
  ------------------
  |  Branch (11272:39): [True: 21.5M, False: 1.50M]
  |  Branch (11272:50): [True: 21.5M, False: 2]
  ------------------
_ZN7httplib6detail6fields11is_obs_textEc:
11274|  1.50M|inline bool is_obs_text(char c) { return 128 <= static_cast<unsigned char>(c); }
_ZN7httplib6detail6divideERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEcNS1_8functionIFvPKcmSC_mEEE:
 6727|  5.40k|           fn) {
 6728|  5.40k|  divide(str.data(), str.size(), d, std::move(fn));
 6729|  5.40k|}
_ZN7httplib6detail6divideEPKcmcNSt3__18functionIFvS2_mS2_mEEE:
 6713|  4.55M|           fn) {
 6714|  4.55M|  const auto it = std::find(data, data + size, d);
 6715|  4.55M|  const auto found = static_cast<std::size_t>(it != data + size);
 6716|  4.55M|  const auto lhs_data = data;
 6717|  4.55M|  const auto lhs_size = static_cast<std::size_t>(it - data);
 6718|  4.55M|  const auto rhs_data = it + found;
 6719|  4.55M|  const auto rhs_size = size - lhs_size - found;
 6720|       |
 6721|  4.55M|  fn(lhs_data, lhs_size, rhs_data, rhs_size);
 6722|  4.55M|}
_ZZNK7httplib6Server18parse_request_lineEPKcRNS_7RequestEENKUlS2_mS2_mE_clES2_mS2_m:
15161|  5.40k|                       const char *rhs_data, std::size_t rhs_size) {
15162|  5.40k|                     req.path =
15163|  5.40k|                         decode_path_component(std::string(lhs_data, lhs_size));
15164|  5.40k|                     detail::parse_query_text(rhs_data, rhs_size, req.params);
15165|  5.40k|                   });
_ZN7httplib21decode_path_componentERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE:
12657|  5.40k|inline std::string decode_path_component(const std::string &component) {
12658|  5.40k|  std::string result;
12659|  5.40k|  result.reserve(component.size());
12660|       |
12661|   359k|  for (size_t i = 0; i < component.size(); i++) {
  ------------------
  |  Branch (12661:22): [True: 354k, False: 5.40k]
  ------------------
12662|   354k|    if (component[i] == '%' && i + 1 < component.size()) {
  ------------------
  |  Branch (12662:9): [True: 21.7k, False: 332k]
  |  Branch (12662:32): [True: 21.6k, False: 30]
  ------------------
12663|  21.6k|      if (component[i + 1] == 'u') {
  ------------------
  |  Branch (12663:11): [True: 6.67k, False: 15.0k]
  ------------------
12664|       |        // Unicode %uXXXX encoding
12665|  6.67k|        auto val = 0;
12666|       |        // 4 digits Unicode codes: val is 0x0000-0xFFFF (from 4 hex digits),
12667|       |        // so to_utf8 writes at most 3 bytes. buff[4] is safe.
12668|  6.67k|        char buff[4];
12669|  6.67k|        size_t len = 0;
12670|  6.67k|        if (detail::from_hex_to_i(component, i + 2, 4, val) &&
  ------------------
  |  Branch (12670:13): [True: 5.22k, False: 1.45k]
  ------------------
12671|  5.22k|            (len = detail::to_utf8(val, buff)) > 0) {
  ------------------
  |  Branch (12671:13): [True: 1.28k, False: 3.94k]
  ------------------
12672|  1.28k|          result.append(buff, len);
12673|  1.28k|          i += 5; // 'u0000'
12674|  5.39k|        } else {
12675|       |          // Not 4 hex digits, or a surrogate, which is no character: the
12676|       |          // escape is kept as it is rather than joining its neighbours
12677|  5.39k|          result += component[i];
12678|  5.39k|        }
12679|  15.0k|      } else {
12680|       |        // Standard %XX encoding
12681|  15.0k|        auto val = 0;
12682|  15.0k|        if (detail::from_hex_to_i(component, i + 1, 2, val)) {
  ------------------
  |  Branch (12682:13): [True: 5.06k, False: 9.95k]
  ------------------
12683|       |          // 2 digits hex codes
12684|  5.06k|          result += static_cast<char>(val);
12685|  5.06k|          i += 2; // 'XX'
12686|  9.95k|        } else {
12687|  9.95k|          result += component[i];
12688|  9.95k|        }
12689|  15.0k|      }
12690|   332k|    } else {
12691|   332k|      result += component[i];
12692|   332k|    }
12693|   354k|  }
12694|  5.40k|  return result;
12695|  5.40k|}
_ZN7httplib6detail13from_hex_to_iERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEmmRi:
 5797|  56.9k|                          int &val) {
 5798|  56.9k|  if (i >= s.size()) { return false; }
  ------------------
  |  Branch (5798:7): [True: 14, False: 56.9k]
  ------------------
 5799|       |
 5800|  56.9k|  val = 0;
 5801|   140k|  for (; cnt; i++, cnt--) {
  ------------------
  |  Branch (5801:10): [True: 107k, False: 32.9k]
  ------------------
 5802|   107k|    if (!s[i]) { return false; }
  ------------------
  |  Branch (5802:9): [True: 20, False: 107k]
  ------------------
 5803|   107k|    auto v = 0;
 5804|   107k|    if (is_hex(s[i], v)) {
  ------------------
  |  Branch (5804:9): [True: 83.1k, False: 24.0k]
  ------------------
 5805|  83.1k|      val = val * 16 + v;
 5806|  83.1k|    } else {
 5807|  24.0k|      return false;
 5808|  24.0k|    }
 5809|   107k|  }
 5810|  32.9k|  return true;
 5811|  56.9k|}
_ZN7httplib6detail6is_hexEcRi:
 5782|   107k|inline bool is_hex(char c, int &v) {
 5783|   107k|  if (is_ascii_digit(c)) {
  ------------------
  |  Branch (5783:7): [True: 52.8k, False: 54.3k]
  ------------------
 5784|  52.8k|    v = c - '0';
 5785|  52.8k|    return true;
 5786|  54.3k|  } else if ('A' <= c && c <= 'F') {
  ------------------
  |  Branch (5786:14): [True: 35.4k, False: 18.9k]
  |  Branch (5786:26): [True: 7.72k, False: 27.6k]
  ------------------
 5787|  7.72k|    v = c - 'A' + 10;
 5788|  7.72k|    return true;
 5789|  46.6k|  } else if ('a' <= c && c <= 'f') {
  ------------------
  |  Branch (5789:14): [True: 27.2k, False: 19.3k]
  |  Branch (5789:26): [True: 22.6k, False: 4.63k]
  ------------------
 5790|  22.6k|    v = c - 'a' + 10;
 5791|  22.6k|    return true;
 5792|  22.6k|  }
 5793|  24.0k|  return false;
 5794|   107k|}
_ZN7httplib6detail14is_ascii_digitEc:
  674|   664k|inline bool is_ascii_digit(char c) { return '0' <= c && c <= '9'; }
  ------------------
  |  Branch (674:45): [True: 608k, False: 55.2k]
  |  Branch (674:57): [True: 201k, False: 407k]
  ------------------
_ZN7httplib6detail7to_utf8EiPc:
 5916|  5.22k|inline size_t to_utf8(int code, char *buff) {
 5917|  5.22k|  if (code < 0x0080) {
  ------------------
  |  Branch (5917:7): [True: 201, False: 5.01k]
  ------------------
 5918|    201|    buff[0] = static_cast<char>(code & 0x7F);
 5919|    201|    return 1;
 5920|  5.01k|  } else if (code < 0x0800) {
  ------------------
  |  Branch (5920:14): [True: 444, False: 4.57k]
  ------------------
 5921|    444|    buff[0] = static_cast<char>(0xC0 | ((code >> 6) & 0x1F));
 5922|    444|    buff[1] = static_cast<char>(0x80 | (code & 0x3F));
 5923|    444|    return 2;
 5924|  4.57k|  } else if (code < 0xD800) {
  ------------------
  |  Branch (5924:14): [True: 358, False: 4.21k]
  ------------------
 5925|    358|    buff[0] = static_cast<char>(0xE0 | ((code >> 12) & 0xF));
 5926|    358|    buff[1] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
 5927|    358|    buff[2] = static_cast<char>(0x80 | (code & 0x3F));
 5928|    358|    return 3;
 5929|  4.21k|  } else if (code < 0xE000) { // D800 - DFFF is invalid...
  ------------------
  |  Branch (5929:14): [True: 3.94k, False: 277]
  ------------------
 5930|  3.94k|    return 0;
 5931|  3.94k|  } else if (code < 0x10000) {
  ------------------
  |  Branch (5931:14): [True: 277, False: 0]
  ------------------
 5932|    277|    buff[0] = static_cast<char>(0xE0 | ((code >> 12) & 0xF));
 5933|    277|    buff[1] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
 5934|    277|    buff[2] = static_cast<char>(0x80 | (code & 0x3F));
 5935|    277|    return 3;
 5936|    277|  } else if (code < 0x110000) {
  ------------------
  |  Branch (5936:14): [True: 0, False: 0]
  ------------------
 5937|      0|    buff[0] = static_cast<char>(0xF0 | ((code >> 18) & 0x7));
 5938|      0|    buff[1] = static_cast<char>(0x80 | ((code >> 12) & 0x3F));
 5939|      0|    buff[2] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
 5940|      0|    buff[3] = static_cast<char>(0x80 | (code & 0x3F));
 5941|      0|    return 4;
 5942|      0|  }
 5943|       |
 5944|       |  // NOTREACHED
 5945|      0|  return 0;
 5946|  5.22k|}
_ZN7httplib6detail16parse_query_textEPKcmRNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS4_8equal_toISA_EEEE:
10103|  5.40k|                             Params &params) {
10104|  5.40k|  std::set<std::string> cache;
10105|  5.40k|  split(data, data + size, '&', [&](const char *b, const char *e) {
10106|  5.40k|    std::string kv(b, e);
10107|  5.40k|    if (cache.find(kv) != cache.end()) { return; }
10108|  5.40k|    cache.insert(std::move(kv));
10109|       |
10110|  5.40k|    std::string key;
10111|  5.40k|    std::string val;
10112|  5.40k|    divide_query_pair(b, e, key, val);
10113|       |
10114|  5.40k|    if (!key.empty()) {
10115|  5.40k|      params.emplace(decode_query_component(key), decode_query_component(val));
10116|  5.40k|    }
10117|  5.40k|  });
10118|  5.40k|}
_ZN7httplib6detail5splitEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 6732|  8.02k|                  std::function<void(const char *, const char *)> fn) {
 6733|  8.02k|  return split(b, e, d, (std::numeric_limits<size_t>::max)(), std::move(fn));
 6734|  8.02k|}
_ZN7httplib6detail5splitEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 6737|  8.02k|                  std::function<void(const char *, const char *)> fn) {
 6738|  8.02k|  size_t i = 0;
 6739|  8.02k|  size_t beg = 0;
 6740|  8.02k|  size_t count = 1;
 6741|       |
 6742|  14.0M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6742:10): [True: 14.0M, False: 0]
  |  Branch (6742:10): [True: 14.0M, False: 8.02k]
  ------------------
 6743|  14.0M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6743:9): [True: 4.82M, False: 9.26M]
  |  Branch (6743:22): [True: 4.82M, False: 0]
  ------------------
 6744|  4.82M|      auto r = trim(b, e, beg, i);
 6745|  4.82M|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6745:11): [True: 4.59M, False: 238k]
  ------------------
 6746|  4.82M|      beg = i + 1;
 6747|  4.82M|      count++;
 6748|  4.82M|    }
 6749|  14.0M|    i++;
 6750|  14.0M|  }
 6751|       |
 6752|  8.02k|  if (i) {
  ------------------
  |  Branch (6752:7): [True: 3.29k, False: 4.73k]
  ------------------
 6753|  3.29k|    auto r = trim(b, e, beg, i);
 6754|  3.29k|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6754:9): [True: 3.15k, False: 136]
  ------------------
 6755|  3.29k|  }
 6756|  8.02k|}
_ZN7httplib6detail4trimEPKcS2_mm:
 6672|  20.9M|                                      size_t right) {
 6673|  20.9M|  while (b + left < e && is_space_or_tab(b[left])) {
  ------------------
  |  Branch (6673:10): [True: 20.9M, False: 1.81k]
  |  Branch (6673:26): [True: 33.4k, False: 20.9M]
  ------------------
 6674|  33.4k|    left++;
 6675|  33.4k|  }
 6676|  20.9M|  while (right > 0 && is_space_or_tab(b[right - 1])) {
  ------------------
  |  Branch (6676:10): [True: 20.9M, False: 1.62k]
  |  Branch (6676:23): [True: 28.1k, False: 20.9M]
  ------------------
 6677|  28.1k|    right--;
 6678|  28.1k|  }
 6679|  20.9M|  return std::make_pair(left, right);
 6680|  20.9M|}
_ZN7httplib6detail15is_space_or_tabEc:
 6525|  41.9M|inline bool is_space_or_tab(char c) { return c == ' ' || c == '\t'; }
  ------------------
  |  Branch (6525:46): [True: 58.1k, False: 41.9M]
  |  Branch (6525:58): [True: 6.03k, False: 41.8M]
  ------------------
_ZZN7httplib6detail16parse_query_textEPKcmRNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS4_8equal_toISA_EEEEENKUlS2_S2_E_clES2_S2_:
10105|  44.6k|  split(data, data + size, '&', [&](const char *b, const char *e) {
10106|  44.6k|    std::string kv(b, e);
10107|  44.6k|    if (cache.find(kv) != cache.end()) { return; }
  ------------------
  |  Branch (10107:9): [True: 14.3k, False: 30.2k]
  ------------------
10108|  30.2k|    cache.insert(std::move(kv));
10109|       |
10110|  30.2k|    std::string key;
10111|  30.2k|    std::string val;
10112|  30.2k|    divide_query_pair(b, e, key, val);
10113|       |
10114|  30.2k|    if (!key.empty()) {
  ------------------
  |  Branch (10114:9): [True: 29.4k, False: 851]
  ------------------
10115|  29.4k|      params.emplace(decode_query_component(key), decode_query_component(val));
10116|  29.4k|    }
10117|  30.2k|  });
_ZN7httplib6detail17divide_query_pairEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESA_:
10093|  30.2k|                              std::string &val) {
10094|  30.2k|  divide(b, static_cast<std::size_t>(e - b), '=',
10095|  30.2k|         [&](const char *lhs_data, std::size_t lhs_size, const char *rhs_data,
10096|  30.2k|             std::size_t rhs_size) {
10097|  30.2k|           key.assign(lhs_data, lhs_size);
10098|  30.2k|           val.assign(rhs_data, rhs_size);
10099|  30.2k|         });
10100|  30.2k|}
_ZZN7httplib6detail17divide_query_pairEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESA_ENKUlS2_mS2_mE_clES2_mS2_m:
10096|  30.2k|             std::size_t rhs_size) {
10097|  30.2k|           key.assign(lhs_data, lhs_size);
10098|  30.2k|           val.assign(rhs_data, rhs_size);
10099|  30.2k|         });
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE7emplaceIJS8_S8_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1328|  29.4k|  template <typename... Args> iterator emplace(Args &&...args) {
 1329|  29.4k|    entries_.emplace_back(std::forward<Args>(args)...);
 1330|  29.4k|    return make_iter(entries_.size() - 1, npos());
 1331|  29.4k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE9make_iterEmm:
 1437|  29.4k|  iterator make_iter(size_type idx, size_type key_idx) {
 1438|  29.4k|    return iterator(entries_.data(), idx, entries_.size(), key_idx);
 1439|  29.4k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE10iterator_tINS2_4pairIS8_S8_EEEC2EPSE_mmm:
 1283|  29.4k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE4nposEv:
 1203|  29.4k|  static size_type npos() { return static_cast<size_type>(-1); }
_ZN7httplib22decode_query_componentERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEb:
12753|  58.8k|                                          bool plus_as_space) {
12754|  58.8k|  std::string result;
12755|  58.8k|  result.reserve(component.size());
12756|       |
12757|   526k|  for (size_t i = 0; i < component.size(); i++) {
  ------------------
  |  Branch (12757:22): [True: 467k, False: 58.8k]
  ------------------
12758|   467k|    if (component[i] == '%' && i + 2 < component.size()) {
  ------------------
  |  Branch (12758:9): [True: 36.7k, False: 430k]
  |  Branch (12758:32): [True: 35.2k, False: 1.50k]
  ------------------
12759|  35.2k|      auto val = 0;
12760|  35.2k|      if (detail::from_hex_to_i(component, i + 1, 2, val)) {
  ------------------
  |  Branch (12760:11): [True: 22.6k, False: 12.6k]
  ------------------
12761|  22.6k|        result += static_cast<char>(val);
12762|  22.6k|        i += 2;
12763|  22.6k|      } else {
12764|  12.6k|        result += component[i];
12765|  12.6k|      }
12766|   432k|    } else if (component[i] == '+' && plus_as_space) {
  ------------------
  |  Branch (12766:16): [True: 1.99k, False: 430k]
  |  Branch (12766:39): [True: 1.99k, False: 0]
  ------------------
12767|  1.99k|      result += ' '; // + becomes space in form-urlencoded
12768|   430k|    } else {
12769|   430k|      result += component[i];
12770|   430k|    }
12771|   467k|  }
12772|  58.8k|  return result;
12773|  58.8k|}
_ZNK7httplib6Server16output_error_logERKNS_5ErrorEPKNS_7RequestE:
16820|  2.52k|                                     const Request *req) const {
16821|  2.52k|  if (error_logger_) {
  ------------------
  |  Branch (16821:7): [True: 0, False: 2.52k]
  ------------------
16822|      0|    std::lock_guard<std::mutex> guard(logger_mutex_);
16823|      0|    error_logger_(err, req);
16824|      0|  }
16825|  2.52k|}
_ZN7httplib6Server14write_responseERNS_6StreamEbRNS_7RequestERNS_8ResponseE:
15172|  4.27k|                                   Request &req, Response &res) {
15173|       |  // NOTE: `req.ranges` should be empty, otherwise it will be applied
15174|       |  // incorrectly to the error content.
15175|  4.27k|  req.ranges.clear();
15176|  4.27k|  return write_response_core(strm, close_connection, req, res, false);
15177|  4.27k|}
_ZN7httplib6Server19write_response_coreERNS_6StreamEbRKNS_7RequestERNS_8ResponseEb:
15188|  5.71k|                                        bool need_apply_ranges) {
15189|  5.71k|  assert(res.status != -1);
  ------------------
  |  Branch (15189:3): [True: 5.71k, False: 0]
  ------------------
15190|       |
15191|  5.71k|  if (400 <= res.status && error_handler_ &&
  ------------------
  |  Branch (15191:7): [True: 4.28k, False: 1.43k]
  |  Branch (15191:28): [True: 0, False: 4.28k]
  ------------------
15192|      0|      error_handler_(req, res) == HandlerResponse::Handled) {
  ------------------
  |  Branch (15192:7): [True: 0, False: 0]
  ------------------
15193|      0|    need_apply_ranges = true;
15194|      0|  }
15195|       |
15196|       |  // Before anything below reads res.headers, which the handlers may have
15197|       |  // filled directly
15198|  5.71k|  detail::erase_invalid_fields(res.headers);
15199|       |
15200|  5.71k|  if (!detail::body_allowed_for_status(res.status)) {
  ------------------
  |  Branch (15200:7): [True: 46, False: 5.67k]
  ------------------
15201|     46|    detail::clear_content(res);
15202|     46|  }
15203|  5.71k|  detail::prefer_assigned_body(res);
15204|       |
15205|  5.71k|  std::string content_type;
15206|  5.71k|  std::string boundary;
15207|  5.71k|  if (need_apply_ranges) { apply_ranges(req, res, content_type, boundary); }
  ------------------
  |  Branch (15207:7): [True: 1.43k, False: 4.27k]
  ------------------
15208|       |
15209|       |  // Prepare additional headers
15210|  5.71k|  if (close_connection ||
  ------------------
  |  Branch (15210:7): [True: 2.72k, False: 2.99k]
  |  Branch (15210:7): [True: 5.31k, False: 403]
  ------------------
15211|  2.99k|      detail::has_header_token(req.headers, "Connection", "close") ||
  ------------------
  |  Branch (15211:7): [True: 2, False: 2.99k]
  ------------------
15212|  2.99k|      400 <= res.status || // Don't leave connections open after errors
  ------------------
  |  Branch (15212:7): [True: 2.59k, False: 403]
  ------------------
15213|       |      // The client withholds the body until `100 Continue`, which was never
15214|       |      // sent, so whether and when the body follows is unknown.
15215|    403|      (req.expect_100_continue_pending_ && detail::has_framed_body(req)) ||
  ------------------
  |  Branch (15215:8): [True: 0, False: 403]
  |  Branch (15215:44): [True: 0, False: 0]
  ------------------
15216|       |      // The body was left partway, e.g. by a content receiver that returned
15217|       |      // false, so the rest of it cannot be told from the next request.
15218|  5.31k|      (req.body_read_started_ && !req.body_consumed_)) {
  ------------------
  |  Branch (15218:8): [True: 0, False: 403]
  |  Branch (15218:34): [True: 0, False: 0]
  ------------------
15219|  5.31k|    res.set_header("Connection", "close");
15220|  5.31k|  } else {
15221|    403|    std::string s = "timeout=";
15222|    403|    s += std::to_string(keep_alive_timeout_sec_);
15223|    403|    if (keep_alive_max_count_ > 0) {
  ------------------
  |  Branch (15223:9): [True: 403, False: 0]
  ------------------
15224|    403|      s += ", max=";
15225|    403|      s += std::to_string(keep_alive_max_count_);
15226|    403|    }
15227|    403|    res.set_header("Keep-Alive", s);
15228|    403|  }
15229|       |
15230|  5.71k|  if ((!res.body.empty() || res.content_length_ > 0 || res.content_provider_) &&
  ------------------
  |  Branch (15230:7): [True: 0, False: 5.71k]
  |  Branch (15230:8): [True: 0, False: 5.71k]
  |  Branch (15230:29): [True: 1.38k, False: 4.33k]
  |  Branch (15230:56): [True: 0, False: 4.33k]
  ------------------
15231|  1.38k|      !res.has_header("Content-Type")) {
  ------------------
  |  Branch (15231:7): [True: 0, False: 1.38k]
  ------------------
15232|      0|    res.set_header("Content-Type", "text/plain");
15233|      0|  }
15234|       |
15235|  5.71k|  detail::set_framing_headers(req, res, boundary, content_type);
15236|       |
15237|  5.71k|  if (req.method == "HEAD" && !res.has_header("Accept-Ranges")) {
  ------------------
  |  Branch (15237:7): [True: 306, False: 5.41k]
  |  Branch (15237:7): [True: 306, False: 5.41k]
  |  Branch (15237:31): [True: 306, False: 0]
  ------------------
15238|    306|    res.set_header("Accept-Ranges", "bytes");
15239|    306|  }
15240|       |
15241|  5.71k|  if (post_routing_handler_) {
  ------------------
  |  Branch (15241:7): [True: 0, False: 5.71k]
  ------------------
15242|      0|    post_routing_handler_(req, res);
15243|      0|    detail::erase_invalid_fields(res.headers);
15244|       |    // Again, for a body or framing headers the handler changed.
15245|      0|    detail::set_framing_headers(req, res, boundary, content_type);
15246|      0|  }
15247|       |
15248|       |  // Response line and headers
15249|  5.71k|  detail::BufferStream bstrm;
15250|  5.71k|  if (!detail::write_response_line(bstrm, res.status)) { return false; }
  ------------------
  |  Branch (15250:7): [True: 0, False: 5.71k]
  ------------------
15251|  5.71k|  if (header_writer_(bstrm, res.headers) <= 0) { return false; }
  ------------------
  |  Branch (15251:7): [True: 0, False: 5.71k]
  ------------------
15252|       |
15253|       |  // Combine a small body with the headers so the whole response leaves in a
15254|       |  // single write. A large body is written on its own instead: a copy of it
15255|       |  // costs more than the extra write saves.
15256|  5.71k|  auto send_body =
15257|  5.71k|      req.method != "HEAD" && detail::body_allowed_for_status(res.status);
  ------------------
  |  Branch (15257:7): [True: 5.41k, False: 306]
  |  Branch (15257:31): [True: 5.37k, False: 33]
  ------------------
15258|  5.71k|  auto body_is_separate = false;
15259|  5.71k|  auto provider_done = false;
15260|  5.71k|  if (send_body && !res.body.empty() && !res.content_provider_) {
  ------------------
  |  Branch (15260:7): [True: 5.37k, False: 339]
  |  Branch (15260:20): [True: 0, False: 5.37k]
  |  Branch (15260:41): [True: 0, False: 0]
  ------------------
15261|      0|    if (res.body.size() < CPPHTTPLIB_SEND_BUFSIZ) {
  ------------------
  |  |  203|      0|#define CPPHTTPLIB_SEND_BUFSIZ size_t(16384u)
  ------------------
  |  Branch (15261:9): [True: 0, False: 0]
  ------------------
15262|      0|      bstrm.write(res.body.data(), res.body.size());
15263|      0|    } else {
15264|      0|      body_is_separate = true;
15265|      0|    }
15266|  5.71k|  } else if (send_body && res.content_provider_ &&
  ------------------
  |  Branch (15266:14): [True: 5.37k, False: 339]
  |  Branch (15266:27): [True: 1.25k, False: 4.12k]
  ------------------
15267|  1.25k|             res.is_file_content_provider_ &&
  ------------------
  |  Branch (15267:14): [True: 1.25k, False: 0]
  ------------------
15268|  1.25k|             res.content_length_ < CPPHTTPLIB_SEND_BUFSIZ) {
  ------------------
  |  |  203|  1.25k|#define CPPHTTPLIB_SEND_BUFSIZ size_t(16384u)
  ------------------
  |  Branch (15268:14): [True: 1.25k, False: 0]
  ------------------
15269|       |    // A small file is read into the same buffer. Other providers may produce
15270|       |    // their data over time, so they are never held back.
15271|  1.25k|    if (!write_content_with_provider(bstrm, req, res, boundary, content_type)) {
  ------------------
  |  Branch (15271:9): [True: 0, False: 1.25k]
  ------------------
15272|      0|      return false;
15273|      0|    }
15274|  1.25k|    provider_done = true;
15275|  1.25k|  }
15276|       |
15277|       |  // Log before writing to avoid race condition with client-side code that
15278|       |  // accesses logger-captured data immediately after receiving the response.
15279|  5.71k|  output_log(req, res);
15280|       |
15281|       |  // Flush buffer
15282|  5.71k|  auto &data = bstrm.get_buffer();
15283|  5.71k|  if (!detail::write_data(strm, data.data(), data.size())) { return false; }
  ------------------
  |  Branch (15283:7): [True: 0, False: 5.71k]
  ------------------
15284|       |
15285|  5.71k|  if (body_is_separate) {
  ------------------
  |  Branch (15285:7): [True: 0, False: 5.71k]
  ------------------
15286|      0|    return detail::write_data(strm, res.body.data(), res.body.size());
15287|      0|  }
15288|       |
15289|       |  // Streaming body
15290|  5.71k|  if (send_body && res.content_provider_) {
  ------------------
  |  Branch (15290:7): [True: 5.37k, False: 339]
  |  Branch (15290:20): [True: 1.25k, False: 4.12k]
  ------------------
15291|  1.25k|    if (!provider_done &&
  ------------------
  |  Branch (15291:9): [True: 0, False: 1.25k]
  ------------------
15292|      0|        !write_content_with_provider(strm, req, res, boundary, content_type)) {
  ------------------
  |  Branch (15292:9): [True: 0, False: 0]
  ------------------
15293|      0|      return false;
15294|      0|    }
15295|  1.25k|    res.content_provider_success_ = true;
15296|  1.25k|  }
15297|       |
15298|  5.71k|  return true;
15299|  5.71k|}
_ZN7httplib6detail20erase_invalid_fieldsERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9217|  5.71k|inline void erase_invalid_fields(Headers &headers) {
 9218|  10.4k|  for (auto it = headers.begin(); it != headers.end();) {
  ------------------
  |  Branch (9218:35): [True: 4.73k, False: 5.71k]
  ------------------
 9219|  4.73k|    if (fields::is_field_valid(it->first, it->second)) {
  ------------------
  |  Branch (9219:9): [True: 4.73k, False: 0]
  ------------------
 9220|  4.73k|      ++it;
 9221|  4.73k|    } else {
 9222|      0|      it = headers.erase(it);
 9223|      0|    }
 9224|  4.73k|  }
 9225|  5.71k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1306|  5.71k|  iterator begin() { return make_iter(0, npos()); }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE9make_iterEmm:
 1437|  57.4k|  iterator make_iter(size_type idx, size_type key_idx) {
 1438|  57.4k|    return iterator(entries_.data(), idx, entries_.size(), key_idx);
 1439|  57.4k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEC2EPSE_mmm:
 1283|  57.4k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEneISE_EEbRKNSC_IT_EE:
 1274|  15.6k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1275|  15.6k|      return idx_ != rhs.idx_;
 1276|  15.6k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1307|  18.1k|  iterator end() { return make_iter(entries_.size(), npos()); }
_ZN7httplib6detail6fields14is_field_validERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
11305|  21.6k|inline bool is_field_valid(const std::string &name, const std::string &value) {
11306|  21.6k|  return is_field_name(name) && is_field_value(value);
  ------------------
  |  Branch (11306:10): [True: 21.6k, False: 0]
  |  Branch (11306:33): [True: 21.6k, False: 0]
  ------------------
11307|  21.6k|}
_ZN7httplib6detail6fields13is_field_nameERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11270|  37.7k|inline bool is_field_name(const std::string &s) { return is_token(s); }
_ZN7httplib6detail6fields8is_tokenERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11262|  37.7k|inline bool is_token(const std::string &s) {
11263|  37.7k|  if (s.empty()) { return false; }
  ------------------
  |  Branch (11263:7): [True: 14, False: 37.7k]
  ------------------
11264|   390k|  for (auto c : s) {
  ------------------
  |  Branch (11264:15): [True: 390k, False: 37.6k]
  ------------------
11265|   390k|    if (!is_token_char(c)) { return false; }
  ------------------
  |  Branch (11265:9): [True: 99, False: 390k]
  ------------------
11266|   390k|  }
11267|  37.6k|  return true;
11268|  37.7k|}
_ZN7httplib6detail6fields13is_token_charEc:
11256|   390k|inline bool is_token_char(char c) {
11257|   390k|  return is_ascii_alnum(c) || c == '!' || c == '#' || c == '$' || c == '%' ||
  ------------------
  |  Branch (11257:10): [True: 355k, False: 34.8k]
  |  Branch (11257:31): [True: 409, False: 34.4k]
  |  Branch (11257:43): [True: 333, False: 34.1k]
  |  Branch (11257:55): [True: 365, False: 33.7k]
  |  Branch (11257:67): [True: 604, False: 33.1k]
  ------------------
11258|  33.1k|         c == '&' || c == '\'' || c == '*' || c == '+' || c == '-' ||
  ------------------
  |  Branch (11258:10): [True: 316, False: 32.8k]
  |  Branch (11258:22): [True: 864, False: 31.9k]
  |  Branch (11258:35): [True: 459, False: 31.5k]
  |  Branch (11258:47): [True: 203, False: 31.3k]
  |  Branch (11258:59): [True: 26.9k, False: 4.38k]
  ------------------
11259|  4.38k|         c == '.' || c == '^' || c == '_' || c == '`' || c == '|' || c == '~';
  ------------------
  |  Branch (11259:10): [True: 328, False: 4.06k]
  |  Branch (11259:22): [True: 1.65k, False: 2.41k]
  |  Branch (11259:34): [True: 220, False: 2.19k]
  |  Branch (11259:46): [True: 199, False: 1.99k]
  |  Branch (11259:58): [True: 492, False: 1.49k]
  |  Branch (11259:70): [True: 1.40k, False: 99]
  ------------------
11260|   390k|}
_ZN7httplib6detail14is_ascii_alnumEc:
  680|   411k|inline bool is_ascii_alnum(char c) {
  681|   411k|  return is_ascii_digit(c) || is_ascii_alpha(c);
  ------------------
  |  Branch (681:10): [True: 4.80k, False: 406k]
  |  Branch (681:31): [True: 365k, False: 41.7k]
  ------------------
  682|   411k|}
_ZN7httplib6detail14is_ascii_alphaEc:
  676|   406k|inline bool is_ascii_alpha(char c) {
  677|   406k|  return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
  ------------------
  |  Branch (677:11): [True: 297k, False: 109k]
  |  Branch (677:23): [True: 295k, False: 2.09k]
  |  Branch (677:37): [True: 75.0k, False: 36.4k]
  |  Branch (677:49): [True: 69.8k, False: 5.28k]
  ------------------
  678|   406k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEptEv:
 1232|  10.5k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEppEv:
 1234|  5.65k|    iterator_t &operator++() {
 1235|       |      // Saturating, so that advancing past the last entry of a key stays at
 1236|       |      // end() instead of running off the container.
 1237|  5.65k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1237:11): [True: 0, False: 5.65k]
  ------------------
 1238|  5.65k|      ++idx_;
 1239|  5.65k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1239:11): [True: 913, False: 4.73k]
  ------------------
 1240|  1.24k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1240:16): [True: 625, False: 624]
  |  Branch (1240:32): [True: 336, False: 289]
  ------------------
 1241|    336|          ++idx_;
 1242|    336|        }
 1243|    913|      }
 1244|  5.65k|      return *this;
 1245|  5.65k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEE7matchesEm:
 1285|    625|    bool matches(size_type i) const {
 1286|    625|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1287|    625|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5eraseENSB_10iterator_tIKNS2_4pairIS8_S8_EEEE:
 1381|     85|  iterator erase(const_iterator pos) {
 1382|     85|    entries_.erase(entries_.begin() + static_cast<difference_type>(pos.idx_));
 1383|     85|    return make_iter(pos.idx_, npos());
 1384|     85|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEC2ISE_TnNS2_9enable_ifIXsr3std14is_convertibleIPT_PSF_EE5valueEiE4typeELi0EEERKNSC_ISJ_EE:
 1228|     85|        : data_(rhs.data_), idx_(rhs.idx_), size_(rhs.size_),
 1229|     85|          key_idx_(rhs.key_idx_) {}
_ZN7httplib6detail23body_allowed_for_statusEi:
13071|  16.8k|inline bool body_allowed_for_status(int status) {
13072|  16.8k|  return status >= 200 && status != StatusCode::NoContent_204 &&
  ------------------
  |  Branch (13072:10): [True: 16.8k, False: 0]
  |  Branch (13072:27): [True: 16.8k, False: 0]
  ------------------
13073|  16.8k|         status != StatusCode::NotModified_304;
  ------------------
  |  Branch (13073:10): [True: 16.7k, False: 125]
  ------------------
13074|  16.8k|}
_ZNK7httplib6Server12apply_rangesERKNS_7RequestERNS_8ResponseERNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEESD_:
16028|  1.43k|                                 std::string &boundary) const {
16029|       |  // A known-length content provider leaves `res.body` empty, so the compressor
16030|       |  // at the end of this function never runs for one (issue #2545). A file-backed
16031|       |  // provider is fully readable right here, so compress it and answer with an
16032|       |  // ordinary body: `Content-Length` and HEAD keep working, and the response
16033|       |  // takes the same path as `set_content()` from here on. Range requests never
16034|       |  // get a content coding, so `Content-Range` still names identity bytes and
16035|       |  // none of the range handling below applies.
16036|  1.43k|  if (apply_static_file_compression(req, res)) { return; }
  ------------------
  |  Branch (16036:7): [True: 0, False: 1.43k]
  ------------------
16037|       |
16038|  1.43k|  if (req.ranges.size() > 1 && res.status == StatusCode::PartialContent_206) {
  ------------------
  |  Branch (16038:7): [True: 88, False: 1.35k]
  |  Branch (16038:32): [True: 85, False: 3]
  ------------------
16039|     85|    auto it = res.headers.find("Content-Type");
16040|     85|    if (it != res.headers.end()) {
  ------------------
  |  Branch (16040:9): [True: 85, False: 0]
  ------------------
16041|     85|      content_type = it->second;
16042|     85|      res.headers.erase(it);
16043|     85|    }
16044|       |
16045|     85|    boundary = detail::make_multipart_data_boundary();
16046|       |
16047|     85|    res.set_header("Content-Type",
16048|     85|                   "multipart/byteranges; boundary=" + boundary);
16049|     85|  }
16050|       |
16051|  1.43k|  auto type =
16052|  1.43k|      compress_ ? detail::encoding_type(req, res) : detail::EncodingType::None;
  ------------------
  |  Branch (16052:7): [True: 1.43k, False: 0]
  ------------------
16053|       |
16054|  1.43k|  if (res.body.empty()) {
  ------------------
  |  Branch (16054:7): [True: 1.43k, False: 0]
  ------------------
16055|  1.43k|    if (res.content_length_ > 0 && req.ranges.size() == 1 &&
  ------------------
  |  Branch (16055:9): [True: 1.38k, False: 56]
  |  Branch (16055:36): [True: 362, False: 1.02k]
  ------------------
16056|    362|        res.status == StatusCode::PartialContent_206) {
  ------------------
  |  Branch (16056:9): [True: 362, False: 0]
  ------------------
16057|    362|      auto offset_and_length = detail::get_range_offset_and_length(
16058|    362|          req.ranges[0], res.content_length_);
16059|       |
16060|    362|      auto content_range = detail::make_content_range_header_field(
16061|    362|          offset_and_length, res.content_length_);
16062|    362|      res.set_header("Content-Range", content_range);
16063|  1.07k|    } else if (res.is_chunked_content_provider_) {
  ------------------
  |  Branch (16063:16): [True: 0, False: 1.07k]
  ------------------
16064|      0|      res.content_coding_ = type;
16065|      0|      if (type != detail::EncodingType::None) {
  ------------------
  |  Branch (16065:11): [True: 0, False: 0]
  ------------------
16066|      0|        res.set_header("Content-Encoding", detail::encoding_name(type));
16067|      0|        res.set_header("Vary", "Accept-Encoding");
16068|      0|      }
16069|      0|    }
16070|  1.43k|  } else {
16071|      0|    if (req.ranges.empty() || res.status != StatusCode::PartialContent_206) {
  ------------------
  |  Branch (16071:9): [True: 0, False: 0]
  |  Branch (16071:31): [True: 0, False: 0]
  ------------------
16072|      0|      ;
16073|      0|    } else if (req.ranges.size() == 1) {
  ------------------
  |  Branch (16073:16): [True: 0, False: 0]
  ------------------
16074|      0|      auto offset_and_length =
16075|      0|          detail::get_range_offset_and_length(req.ranges[0], res.body.size());
16076|      0|      auto offset = offset_and_length.first;
16077|      0|      auto length = offset_and_length.second;
16078|       |
16079|      0|      auto content_range = detail::make_content_range_header_field(
16080|      0|          offset_and_length, res.body.size());
16081|      0|      res.set_header("Content-Range", content_range);
16082|       |
16083|      0|      assert(offset + length <= res.body.size());
  ------------------
  |  Branch (16083:7): [True: 0, False: 0]
  ------------------
16084|      0|      res.body = res.body.substr(offset, length);
16085|      0|    } else {
16086|      0|      std::string data;
16087|      0|      detail::make_multipart_ranges_data(req, res, boundary, content_type,
16088|      0|                                         res.body.size(), data);
16089|      0|      res.body.swap(data);
16090|      0|    }
16091|       |
16092|      0|    if (type != detail::EncodingType::None) {
  ------------------
  |  Branch (16092:9): [True: 0, False: 0]
  ------------------
16093|      0|      output_pre_compression_log(req, res);
16094|       |
16095|      0|      if (auto compressor = detail::make_compressor(type)) {
  ------------------
  |  Branch (16095:16): [True: 0, False: 0]
  ------------------
16096|      0|        std::string compressed;
16097|      0|        if (compressor->compress(res.body.data(), res.body.size(), true,
  ------------------
  |  Branch (16097:13): [True: 0, False: 0]
  ------------------
16098|      0|                                 [&](const char *data, size_t data_len) {
16099|      0|                                   compressed.append(data, data_len);
16100|      0|                                   return true;
16101|      0|                                 })) {
16102|      0|          res.body.swap(compressed);
16103|      0|          res.set_header("Content-Encoding", detail::encoding_name(type));
16104|      0|          res.set_header("Vary", "Accept-Encoding");
16105|      0|        }
16106|      0|      }
16107|      0|    }
16108|       |
16109|      0|    res.content_length_ = res.body.size();
16110|      0|  }
16111|  1.43k|}
_ZNK7httplib6Server29apply_static_file_compressionERKNS_7RequestERNS_8ResponseE:
15996|  1.43k|                                                  Response &res) const {
15997|  1.43k|  auto type = res.content_coding_;
15998|  1.43k|  if (type == detail::EncodingType::None || !res.content_provider_) {
  ------------------
  |  Branch (15998:7): [True: 1.43k, False: 0]
  |  Branch (15998:45): [True: 0, False: 0]
  ------------------
15999|  1.43k|    return false;
16000|  1.43k|  }
16001|       |
16002|      0|  auto compressor = detail::make_compressor(type);
16003|      0|  if (!compressor) { return false; }
  ------------------
  |  Branch (16003:7): [True: 0, False: 0]
  ------------------
16004|       |
16005|      0|  output_pre_compression_log(req, res);
16006|       |
16007|      0|  std::string compressed;
16008|      0|  if (!detail::compress_content_provider(res.content_provider_,
  ------------------
  |  Branch (16008:7): [True: 0, False: 0]
  ------------------
16009|      0|                                         res.content_length_, *compressor,
16010|      0|                                         compressed)) {
16011|      0|    return false;
16012|      0|  }
16013|       |
16014|      0|  res.body.swap(compressed);
16015|       |
16016|       |  // The provider was consumed in full, so its releaser hears about a success.
16017|      0|  res.content_provider_success_ = true;
16018|      0|  detail::clear_content_provider(res);
16019|       |
16020|      0|  res.set_header("Content-Encoding", detail::encoding_name(type));
16021|      0|  res.set_header("Vary", "Accept-Encoding");
16022|       |
16023|      0|  return true;
16024|      0|}
_ZN7httplib8DataSinkC2Ev:
 1601|  1.46k|  DataSink() : os(&sb_), sb_(*this) {}
_ZN7httplib8DataSink19data_sink_streambufC2ERS0_:
 1624|  1.46k|    explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}
_ZN7httplib6detail22clear_content_providerERNS_8ResponseE:
13033|  1.75k|inline void clear_content_provider(Response &res) {
13034|  1.75k|  auto releaser = std::move(res.content_provider_resource_releaser_);
13035|  1.75k|  auto success = res.content_provider_success_;
13036|       |
13037|  1.75k|  res.content_length_ = 0;
13038|  1.75k|  res.content_provider_ = nullptr;
13039|  1.75k|  res.content_provider_resource_releaser_ = nullptr;
13040|  1.75k|  res.is_chunked_content_provider_ = false;
13041|  1.75k|  res.is_file_content_provider_ = false;
13042|  1.75k|  res.content_provider_success_ = false;
13043|  1.75k|  res.content_coding_ = EncodingType::None;
13044|  1.75k|  res.file_content_path_.clear();
13045|  1.75k|  res.file_content_content_type_.clear();
13046|       |
13047|  1.75k|  if (releaser) { releaser(success); }
  ------------------
  |  Branch (13047:7): [True: 0, False: 1.75k]
  ------------------
13048|  1.75k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4findERKS8_:
 1340|     85|  iterator find(const std::string &key) {
 1341|     85|    auto i = index_of(key);
 1342|     85|    return i == npos() ? end() : make_iter(i, i);
  ------------------
  |  Branch (1342:12): [True: 0, False: 85]
  ------------------
 1343|     85|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE8index_ofERKS8_:
 1430|  79.8k|  size_type index_of(const std::string &key) const {
 1431|   274k|    for (size_type i = 0; i < entries_.size(); i++) {
  ------------------
  |  Branch (1431:27): [True: 212k, False: 61.7k]
  ------------------
 1432|   212k|      if (keys_equal(entries_[i].first, key)) { return i; }
  ------------------
  |  Branch (1432:11): [True: 18.1k, False: 194k]
  ------------------
 1433|   212k|    }
 1434|  61.7k|    return npos();
 1435|  79.8k|  }
_ZN7httplib6detail28make_multipart_data_boundaryEv:
10734|     85|inline std::string make_multipart_data_boundary() {
10735|     85|  return "--cpp-httplib-multipart-data-" + detail::random_string(16);
10736|     85|}
_ZN7httplib6detail13random_stringEm:
10722|     85|inline std::string random_string(size_t length) {
10723|     85|  constexpr const char data[] =
10724|     85|      "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
10725|       |
10726|     85|  std::string result(length, '\0');
10727|     85|  fill_random_bytes(reinterpret_cast<unsigned char *>(&result[0]), length);
10728|  1.36k|  for (auto &c : result) {
  ------------------
  |  Branch (10728:16): [True: 1.36k, False: 85]
  ------------------
10729|  1.36k|    c = data[static_cast<unsigned char>(c) % (sizeof(data) - 1)];
10730|  1.36k|  }
10731|     85|  return result;
10732|     85|}
_ZN7httplib6detail17fill_random_bytesEPhm:
 6159|     85|inline void fill_random_bytes(unsigned char *out, size_t n) {
 6160|     85|  thread_local std::random_device rd;
 6161|     85|  size_t filled = 0;
 6162|    425|  while (filled < n) {
  ------------------
  |  Branch (6162:10): [True: 340, False: 85]
  ------------------
 6163|    340|    auto v = rd();
 6164|  1.70k|    for (size_t b = 0; b < sizeof(v) && filled < n; ++b, ++filled) {
  ------------------
  |  Branch (6164:24): [True: 1.36k, False: 340]
  |  Branch (6164:41): [True: 1.36k, False: 0]
  ------------------
 6165|  1.36k|      out[filled] = static_cast<unsigned char>((v >> (b * 8)) & 0xFFu);
 6166|  1.36k|    }
 6167|    340|  }
 6168|     85|}
_ZN7httplib6detail13encoding_typeERKNS_7RequestERKNS_8ResponseE:
 8774|  1.43k|inline EncodingType encoding_type(const Request &req, const Response &res) {
 8775|  1.43k|  return encoding_type(req, res, res.get_header_value("Content-Type"));
 8776|  1.43k|}
_ZN7httplib6detail13encoding_typeERKNS_7RequestERKNS_8ResponseERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEE:
 8764|  1.43k|                                  const std::string &content_type) {
 8765|       |  // The response already names a content coding of its own: a handler serving
 8766|       |  // a body it encoded itself (pre-compressed static assets, say), or a mount
 8767|       |  // point whose headers name the coding its files are stored in. Applying one
 8768|       |  // on top of that would double-encode the body and append a second
 8769|       |  // `Content-Encoding` field line.
 8770|  1.43k|  if (res.has_header("Content-Encoding")) { return EncodingType::None; }
  ------------------
  |  Branch (8770:7): [True: 0, False: 1.43k]
  ------------------
 8771|  1.43k|  return encoding_type(req, content_type);
 8772|  1.43k|}
_ZN7httplib6detail13encoding_typeERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 8706|  1.43k|                                  const std::string &content_type) {
 8707|  1.43k|  if (!can_compress_content_type(content_type)) { return EncodingType::None; }
  ------------------
  |  Branch (8707:7): [True: 145, False: 1.29k]
  ------------------
 8708|       |
 8709|  1.29k|  auto s = get_combined_header_value(req.headers, "Accept-Encoding");
 8710|  1.29k|  if (s.empty()) { return EncodingType::None; }
  ------------------
  |  Branch (8710:7): [True: 1.15k, False: 139]
  ------------------
 8711|       |
 8712|       |  // Single-pass: iterate tokens and track the best supported encoding.
 8713|       |  // Server preference breaks ties (br > gzip > zstd).
 8714|    139|  EncodingType best = EncodingType::None;
 8715|    139|  double best_q = 0.0; // q=0 means "not acceptable"
 8716|       |
 8717|       |  // Server preference: Brotli > Gzip > Zstd (lower = more preferred)
 8718|    139|  auto priority = [](EncodingType t) -> int {
 8719|    139|    switch (t) {
 8720|    139|    case EncodingType::Brotli: return 0;
 8721|    139|    case EncodingType::Gzip: return 1;
 8722|    139|    case EncodingType::Zstd: return 2;
 8723|    139|    default: return 3;
 8724|    139|    }
 8725|    139|  };
 8726|       |
 8727|    139|  std::string name;
 8728|    139|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
 8729|    139|    double quality = 1.0;
 8730|    139|    if (!parse_quality(b, e, name, quality)) { return; }
 8731|    139|    if (quality <= 0.0) { return; }
 8732|       |
 8733|    139|    EncodingType type = EncodingType::None;
 8734|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
 8735|       |    if (case_ignore::equal(name, "br")) { type = EncodingType::Brotli; }
 8736|       |#endif
 8737|    139|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
 8738|    139|    if (type == EncodingType::None && case_ignore::equal(name, "gzip")) {
 8739|    139|      type = EncodingType::Gzip;
 8740|    139|    }
 8741|    139|#endif
 8742|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
 8743|       |    if (type == EncodingType::None && case_ignore::equal(name, "zstd")) {
 8744|       |      type = EncodingType::Zstd;
 8745|       |    }
 8746|       |#endif
 8747|       |
 8748|    139|    if (type == EncodingType::None) { return; }
 8749|       |
 8750|       |    // Higher q-value wins; for equal q, server preference breaks ties
 8751|    139|    if (quality > best_q ||
 8752|    139|        (quality == best_q && priority(type) < priority(best))) {
 8753|    139|      best_q = quality;
 8754|    139|      best = type;
 8755|    139|    }
 8756|    139|  });
 8757|       |
 8758|    139|  return best;
 8759|  1.29k|}
_ZN7httplib6detail25can_compress_content_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8627|  1.43k|inline bool can_compress_content_type(const std::string &content_type) {
 8628|       |  // Media types are case-insensitive (RFC 9110 §8.3.1)
 8629|  1.43k|  auto mime_type = case_ignore::to_lower(extract_media_type(content_type));
 8630|       |
 8631|  1.43k|  static const char *const compressible[] = {
 8632|  1.43k|      "image/svg+xml",
 8633|  1.43k|      "application/javascript",
 8634|  1.43k|      "application/x-javascript",
 8635|  1.43k|      "application/json",
 8636|  1.43k|      "application/ld+json",
 8637|  1.43k|      "application/xml",
 8638|  1.43k|      "application/xhtml+xml",
 8639|  1.43k|      "application/rss+xml",
 8640|  1.43k|      "application/atom+xml",
 8641|  1.43k|      "application/xslt+xml",
 8642|  1.43k|      "application/protobuf",
 8643|  1.43k|  };
 8644|       |
 8645|  15.8k|  for (auto type : compressible) {
  ------------------
  |  Branch (8645:18): [True: 15.8k, False: 1.43k]
  ------------------
 8646|  15.8k|    if (mime_type == type) { return true; }
  ------------------
  |  Branch (8646:9): [True: 0, False: 15.8k]
  ------------------
 8647|  15.8k|  }
 8648|  1.43k|  return mime_type != "text/event-stream" && !mime_type.rfind("text/", 0);
  ------------------
  |  Branch (8648:10): [True: 1.43k, False: 0]
  |  Branch (8648:46): [True: 1.29k, False: 145]
  ------------------
 8649|  1.43k|}
_ZN7httplib6detail11case_ignore8to_lowerERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
  710|  3.03k|inline std::string to_lower(const std::string &s) {
  711|  3.03k|  std::string result = s;
  712|  3.03k|  std::transform(
  713|  3.03k|      result.begin(), result.end(), result.begin(),
  714|  3.03k|      [](unsigned char c) { return static_cast<char>(to_lower(c)); });
  715|  3.03k|  return result;
  716|  3.03k|}
_ZZN7httplib6detail11case_ignore8to_lowerERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEENKUlhE_clEh:
  714|  19.7k|      [](unsigned char c) { return static_cast<char>(to_lower(c)); });
_ZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEE:
 8597|  4.51M|                   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|  4.51M|  auto media_type = content_type;
 8601|  4.51M|  auto semicolon_pos = media_type.find(';');
 8602|  4.51M|  if (semicolon_pos != std::string::npos) {
  ------------------
  |  Branch (8602:7): [True: 85, False: 4.51M]
  ------------------
 8603|     85|    auto param_str = media_type.substr(semicolon_pos + 1);
 8604|     85|    media_type = media_type.substr(0, semicolon_pos);
 8605|       |
 8606|     85|    if (params) {
  ------------------
  |  Branch (8606:9): [True: 0, False: 85]
  ------------------
 8607|       |      // Parse parameters: key=value pairs separated by ';'
 8608|      0|      split_unquoted(param_str.data(), param_str.data() + param_str.size(), ';',
 8609|      0|                     [&](const char *b, const char *e) {
 8610|      0|                       std::string key;
 8611|      0|                       std::string val;
 8612|      0|                       divide_param_pair(b, e, key, val);
 8613|       |                       // Parameter names are case-insensitive (RFC 9110
 8614|       |                       // §5.6.6)
 8615|      0|                       if (!key.empty()) {
 8616|      0|                         params->emplace(case_ignore::to_lower(trim_copy(key)),
 8617|      0|                                         unquote_param(val));
 8618|      0|                       }
 8619|      0|                     });
 8620|      0|    }
 8621|     85|  }
 8622|       |
 8623|       |  // Trim whitespace from media type
 8624|  4.51M|  return trim_copy(media_type);
 8625|  4.51M|}
_ZN7httplib6detail9trim_copyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6682|  9.02M|inline std::string trim_copy(const std::string &s) {
 6683|  9.02M|  auto r = trim(s.data(), s.data() + s.size(), 0, s.size());
 6684|  9.02M|  return s.substr(r.first, r.second - r.first);
 6685|  9.02M|}
_ZZN7httplib6detail13encoding_typeERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEENKUlPKcSE_E_clESE_SE_:
 8728|  4.26k|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
 8729|  4.26k|    double quality = 1.0;
 8730|  4.26k|    if (!parse_quality(b, e, name, quality)) { return; }
  ------------------
  |  Branch (8730:9): [True: 240, False: 4.02k]
  ------------------
 8731|  4.02k|    if (quality <= 0.0) { return; }
  ------------------
  |  Branch (8731:9): [True: 198, False: 3.82k]
  ------------------
 8732|       |
 8733|  3.82k|    EncodingType type = EncodingType::None;
 8734|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
 8735|       |    if (case_ignore::equal(name, "br")) { type = EncodingType::Brotli; }
 8736|       |#endif
 8737|  3.82k|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
 8738|  3.82k|    if (type == EncodingType::None && case_ignore::equal(name, "gzip")) {
  ------------------
  |  Branch (8738:9): [True: 3.82k, False: 0]
  |  Branch (8738:39): [True: 819, False: 3.00k]
  ------------------
 8739|    819|      type = EncodingType::Gzip;
 8740|    819|    }
 8741|  3.82k|#endif
 8742|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
 8743|       |    if (type == EncodingType::None && case_ignore::equal(name, "zstd")) {
 8744|       |      type = EncodingType::Zstd;
 8745|       |    }
 8746|       |#endif
 8747|       |
 8748|  3.82k|    if (type == EncodingType::None) { return; }
  ------------------
  |  Branch (8748:9): [True: 3.00k, False: 819]
  ------------------
 8749|       |
 8750|       |    // Higher q-value wins; for equal q, server preference breaks ties
 8751|    819|    if (quality > best_q ||
  ------------------
  |  Branch (8751:9): [True: 34, False: 785]
  ------------------
 8752|    785|        (quality == best_q && priority(type) < priority(best))) {
  ------------------
  |  Branch (8752:10): [True: 591, False: 194]
  |  Branch (8752:31): [True: 0, False: 591]
  ------------------
 8753|     34|      best_q = quality;
 8754|     34|      best = type;
 8755|     34|    }
 8756|    819|  });
_ZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERd:
 8652|  4.51M|                          double &quality) {
 8653|  4.51M|  quality = 1.0;
 8654|  4.51M|  token.clear();
 8655|       |
 8656|       |  // Split on first ';': left = token name, right = parameters
 8657|  4.51M|  const char *params_b = nullptr;
 8658|  4.51M|  std::size_t params_len = 0;
 8659|       |
 8660|  4.51M|  divide(
 8661|  4.51M|      b, static_cast<std::size_t>(e - b), ';',
 8662|  4.51M|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 8663|  4.51M|        auto r = trim(lb, lb + llen, 0, llen);
 8664|  4.51M|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
 8665|  4.51M|        params_b = rb;
 8666|  4.51M|        params_len = rlen;
 8667|  4.51M|      });
 8668|       |
 8669|  4.51M|  if (token.empty()) { return false; }
  ------------------
  |  Branch (8669:7): [True: 893, False: 4.51M]
  ------------------
 8670|  4.51M|  if (params_len == 0) { return true; }
  ------------------
  |  Branch (8670:7): [True: 4.48M, False: 27.0k]
  ------------------
 8671|       |
 8672|       |  // Scan parameters for q= (stops on first match)
 8673|  27.0k|  bool invalid = false;
 8674|  27.0k|  split_find(params_b, params_b + params_len, ';',
 8675|  27.0k|             (std::numeric_limits<size_t>::max)(),
 8676|  27.0k|             [&](const char *pb, const char *pe) -> bool {
 8677|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 8678|  27.0k|               auto len = static_cast<size_t>(pe - pb);
 8679|  27.0k|               if (len < 2) { return false; }
 8680|  27.0k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
 8681|  27.0k|                 return false;
 8682|  27.0k|               }
 8683|       |
 8684|       |               // Trim the value portion
 8685|  27.0k|               auto r = trim(pb, pe, 2, len);
 8686|  27.0k|               if (r.first >= r.second) {
 8687|  27.0k|                 invalid = true;
 8688|  27.0k|                 return true;
 8689|  27.0k|               }
 8690|       |
 8691|  27.0k|               double v = 0.0;
 8692|  27.0k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 8693|  27.0k|               if (res.ec != std::errc{} || res.ptr != pb + r.second ||
 8694|  27.0k|                   v < 0.0 || v > 1.0) {
 8695|  27.0k|                 invalid = true;
 8696|  27.0k|                 return true;
 8697|  27.0k|               }
 8698|  27.0k|               quality = v;
 8699|  27.0k|               return true;
 8700|  27.0k|             });
 8701|       |
 8702|  27.0k|  return !invalid;
 8703|  4.51M|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_mS2_mE_clES2_mS2_m:
 8662|  4.51M|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 8663|  4.51M|        auto r = trim(lb, lb + llen, 0, llen);
 8664|  4.51M|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
  ------------------
  |  Branch (8664:13): [True: 4.51M, False: 893]
  ------------------
 8665|  4.51M|        params_b = rb;
 8666|  4.51M|        params_len = rlen;
 8667|  4.51M|      });
_ZN7httplib6detail10split_findEPKcS2_cmNSt3__18functionIFbS2_S2_EEE:
 6812|  35.5k|                       std::function<bool(const char *, const char *)> fn) {
 6813|  35.5k|  size_t i = 0;
 6814|  35.5k|  size_t beg = 0;
 6815|  35.5k|  size_t count = 1;
 6816|       |
 6817|  4.81M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6817:10): [True: 4.81M, False: 0]
  |  Branch (6817:10): [True: 4.77M, False: 35.0k]
  ------------------
 6818|  4.77M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6818:9): [True: 2.50M, False: 2.26M]
  |  Branch (6818:22): [True: 2.50M, False: 0]
  ------------------
 6819|  2.50M|      auto r = trim(b, e, beg, i);
 6820|  2.50M|      if (r.first < r.second) {
  ------------------
  |  Branch (6820:11): [True: 196k, False: 2.31M]
  ------------------
 6821|   196k|        auto found = fn(&b[r.first], &b[r.second]);
 6822|   196k|        if (found) { return true; }
  ------------------
  |  Branch (6822:13): [True: 435, False: 195k]
  ------------------
 6823|   196k|      }
 6824|  2.50M|      beg = i + 1;
 6825|  2.50M|      count++;
 6826|  2.50M|    }
 6827|  4.77M|    i++;
 6828|  4.77M|  }
 6829|       |
 6830|  35.0k|  if (i) {
  ------------------
  |  Branch (6830:7): [True: 32.7k, False: 2.29k]
  ------------------
 6831|  32.7k|    auto r = trim(b, e, beg, i);
 6832|  32.7k|    if (r.first < r.second) {
  ------------------
  |  Branch (6832:9): [True: 32.4k, False: 314]
  ------------------
 6833|  32.4k|      auto found = fn(&b[r.first], &b[r.second]);
 6834|  32.4k|      if (found) { return true; }
  ------------------
  |  Branch (6834:11): [True: 26.9k, False: 5.53k]
  ------------------
 6835|  32.4k|    }
 6836|  32.7k|  }
 6837|       |
 6838|  8.14k|  return false;
 6839|  35.0k|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_S2_E_clES2_S2_:
 8676|  31.9k|             [&](const char *pb, const char *pe) -> bool {
 8677|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 8678|  31.9k|               auto len = static_cast<size_t>(pe - pb);
 8679|  31.9k|               if (len < 2) { return false; }
  ------------------
  |  Branch (8679:20): [True: 3.77k, False: 28.1k]
  ------------------
 8680|  28.1k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
  ------------------
  |  Branch (8680:21): [True: 5.30k, False: 22.8k]
  |  Branch (8680:37): [True: 4.30k, False: 997]
  |  Branch (8680:54): [True: 2.01k, False: 21.8k]
  ------------------
 8681|  6.31k|                 return false;
 8682|  6.31k|               }
 8683|       |
 8684|       |               // Trim the value portion
 8685|  21.8k|               auto r = trim(pb, pe, 2, len);
 8686|  21.8k|               if (r.first >= r.second) {
  ------------------
  |  Branch (8686:20): [True: 412, False: 21.4k]
  ------------------
 8687|    412|                 invalid = true;
 8688|    412|                 return true;
 8689|    412|               }
 8690|       |
 8691|  21.4k|               double v = 0.0;
 8692|  21.4k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 8693|  21.4k|               if (res.ec != std::errc{} || res.ptr != pb + r.second ||
  ------------------
  |  Branch (8693:20): [True: 496, False: 20.9k]
  |  Branch (8693:45): [True: 230, False: 20.7k]
  ------------------
 8694|  20.7k|                   v < 0.0 || v > 1.0) {
  ------------------
  |  Branch (8694:20): [True: 0, False: 20.7k]
  |  Branch (8694:31): [True: 340, False: 20.3k]
  ------------------
 8695|  1.06k|                 invalid = true;
 8696|  1.06k|                 return true;
 8697|  1.06k|               }
 8698|  20.3k|               quality = v;
 8699|  20.3k|               return true;
 8700|  21.4k|             });
_ZN7httplib6detail10from_charsEPKcS2_Rd:
  851|  21.4k|                                            double &value) {
  852|  21.4k|  value = 0.0;
  853|  21.4k|  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|  21.4k|  static const double powers_of_ten[] = {
  858|  21.4k|      1e0,  1e1,  1e2,  1e3,  1e4,  1e5,  1e6,  1e7,  1e8, 1e9,
  859|  21.4k|      1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18};
  860|  21.4k|  const int max_frac_digits =
  861|  21.4k|      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|  21.4k|  uint64_t mantissa = 0;
  872|  21.4k|  int frac_digits = 0;
  873|  21.4k|  bool seen_digit = false;
  874|       |
  875|  21.4k|  const uint64_t limit = ((std::numeric_limits<uint64_t>::max)() - 9) / 10;
  876|  21.4k|  auto accumulate = [&](char c) {
  877|  21.4k|    if (mantissa <= limit) {
  878|  21.4k|      mantissa = mantissa * 10 + static_cast<uint64_t>(c - '0');
  879|  21.4k|      return true;
  880|  21.4k|    }
  881|  21.4k|    return false;
  882|  21.4k|  };
  883|       |
  884|  50.6k|  for (; p != last && is_ascii_digit(*p); ++p) {
  ------------------
  |  Branch (884:10): [True: 30.2k, False: 20.3k]
  |  Branch (884:23): [True: 29.1k, False: 1.14k]
  ------------------
  885|  29.1k|    seen_digit = true;
  886|  29.1k|    accumulate(*p);
  887|  29.1k|  }
  888|       |
  889|  21.4k|  if (p != last && *p == '.') {
  ------------------
  |  Branch (889:7): [True: 1.14k, False: 20.3k]
  |  Branch (889:20): [True: 665, False: 481]
  ------------------
  890|    665|    ++p;
  891|  3.12k|    for (; p != last && is_ascii_digit(*p); ++p) {
  ------------------
  |  Branch (891:12): [True: 2.48k, False: 644]
  |  Branch (891:25): [True: 2.46k, False: 21]
  ------------------
  892|  2.46k|      seen_digit = true;
  893|  2.46k|      if (frac_digits < max_frac_digits && accumulate(*p)) { ++frac_digits; }
  ------------------
  |  Branch (893:11): [True: 2.10k, False: 361]
  |  Branch (893:44): [True: 1.87k, False: 228]
  ------------------
  894|  2.46k|    }
  895|    665|  }
  896|       |
  897|  21.4k|  if (!seen_digit) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (897:7): [True: 496, False: 20.9k]
  ------------------
  898|       |
  899|  20.9k|  value = static_cast<double>(mantissa) / powers_of_ten[frac_digits];
  900|  20.9k|  return {p, std::errc{}};
  901|  21.4k|}
_ZZN7httplib6detail10from_charsEPKcS2_RdENKUlcE_clEc:
  876|  31.2k|  auto accumulate = [&](char c) {
  877|  31.2k|    if (mantissa <= limit) {
  ------------------
  |  Branch (877:9): [True: 30.1k, False: 1.10k]
  ------------------
  878|  30.1k|      mantissa = mantissa * 10 + static_cast<uint64_t>(c - '0');
  879|  30.1k|      return true;
  880|  30.1k|    }
  881|  1.10k|    return false;
  882|  31.2k|  };
_ZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  3.82k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  3.82k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 1.09k, False: 2.72k]
  ------------------
  729|  1.09k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 819, False: 278]
  ------------------
  730|  1.09k|           return to_lower(ca) == to_lower(cb);
  731|  1.09k|         });
  732|  3.82k|}
_ZZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  3.64k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  3.64k|           return to_lower(ca) == to_lower(cb);
  731|  3.64k|         });
_ZZN7httplib6detail13encoding_typeERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEENKUlNS0_12EncodingTypeEE_clESD_:
 8718|  1.18k|  auto priority = [](EncodingType t) -> int {
 8719|  1.18k|    switch (t) {
 8720|      0|    case EncodingType::Brotli: return 0;
  ------------------
  |  Branch (8720:5): [True: 0, False: 1.18k]
  ------------------
 8721|  1.18k|    case EncodingType::Gzip: return 1;
  ------------------
  |  Branch (8721:5): [True: 1.18k, False: 0]
  ------------------
 8722|      0|    case EncodingType::Zstd: return 2;
  ------------------
  |  Branch (8722:5): [True: 0, False: 1.18k]
  ------------------
 8723|      0|    default: return 3;
  ------------------
  |  Branch (8723:5): [True: 0, False: 1.18k]
  ------------------
 8724|  1.18k|    }
 8725|  1.18k|  };
_ZN7httplib6detail27get_range_offset_and_lengthENSt3__14pairIllEEm:
11071|  1.67k|get_range_offset_and_length(Range r, size_t content_length) {
11072|  1.67k|  assert(r.first != -1 && r.second != -1);
  ------------------
  |  Branch (11072:3): [True: 1.67k, False: 0]
  |  Branch (11072:3): [True: 1.67k, False: 0]
  |  Branch (11072:3): [True: 1.67k, False: 0]
  ------------------
11073|  1.67k|  assert(0 <= r.first && r.first < static_cast<ssize_t>(content_length));
  ------------------
  |  Branch (11073:3): [True: 1.67k, False: 0]
  |  Branch (11073:3): [True: 1.67k, False: 0]
  |  Branch (11073:3): [True: 1.67k, False: 0]
  ------------------
11074|  1.67k|  assert(r.first <= r.second &&
  ------------------
  |  Branch (11074:3): [True: 1.67k, False: 0]
  |  Branch (11074:3): [True: 1.67k, False: 0]
  |  Branch (11074:3): [True: 1.67k, False: 0]
  ------------------
11075|  1.67k|         r.second < static_cast<ssize_t>(content_length));
11076|  1.67k|  (void)(content_length);
11077|  1.67k|  return std::make_pair(static_cast<size_t>(r.first),
11078|  1.67k|                        static_cast<size_t>(r.second - r.first) + 1);
11079|  1.67k|}
_ZN7httplib6detail31make_content_range_header_fieldERKNSt3__14pairImmEEm:
11082|    963|    const std::pair<size_t, size_t> &offset_and_length, size_t content_length) {
11083|    963|  auto st = offset_and_length.first;
11084|    963|  auto ed = st + offset_and_length.second - 1;
11085|       |
11086|    963|  std::string field = "bytes ";
11087|    963|  field += std::to_string(st);
11088|    963|  field += '-';
11089|    963|  field += std::to_string(ed);
11090|    963|  field += '/';
11091|    963|  field += std::to_string(content_length);
11092|    963|  return field;
11093|    963|}
_ZN7httplib8Response10set_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_:
13151|  16.8k|                                 const std::string &val) {
13152|  16.8k|  detail::set_header(headers, key, val);
13153|  16.8k|}
_ZN7httplib6detail10set_headerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SE_:
 9211|  16.8k|                       const std::string &val) {
 9212|  16.8k|  if (fields::is_field_valid(key, val)) { headers.emplace(key, val); }
  ------------------
  |  Branch (9212:7): [True: 16.8k, False: 0]
  ------------------
 9213|  16.8k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE7emplaceIJRKS8_SE_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1328|  32.7k|  template <typename... Args> iterator emplace(Args &&...args) {
 1329|  32.7k|    entries_.emplace_back(std::forward<Args>(args)...);
 1330|  32.7k|    return make_iter(entries_.size() - 1, npos());
 1331|  32.7k|  }
_ZNK7httplib8Response10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
13136|  3.12k|inline bool Response::has_header(const std::string &key) const {
13137|  3.12k|  return headers.find(key) != headers.end();
13138|  3.12k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4findERKS8_:
 1345|  30.8k|  const_iterator find(const std::string &key) const {
 1346|  30.8k|    auto i = index_of(key);
 1347|  30.8k|    return i == npos() ? end() : make_citer(i, i);
  ------------------
  |  Branch (1347:12): [True: 26.0k, False: 4.77k]
  ------------------
 1348|  30.8k|  }
_ZN7httplib6detail19set_framing_headersERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEESE_:
13089|  5.71k|                                const std::string &content_type) {
13090|       |  // A HEAD response may give the length a GET would have had (RFC 9110 9.3.2).
13091|  5.71k|  auto head_length = req.method == "HEAD"
  ------------------
  |  Branch (13091:22): [True: 306, False: 5.41k]
  ------------------
13092|  5.71k|                         ? res.get_header_value("Content-Length")
13093|  5.71k|                         : std::string();
13094|  5.71k|  res.headers.erase("Content-Length");
13095|  5.71k|  res.headers.erase("Transfer-Encoding");
13096|       |
13097|  5.71k|  if (!body_allowed_for_status(res.status)) { return; }
  ------------------
  |  Branch (13097:7): [True: 46, False: 5.67k]
  ------------------
13098|       |
13099|  5.67k|  if (res.content_provider_) {
  ------------------
  |  Branch (13099:7): [True: 1.38k, False: 4.28k]
  ------------------
13100|  1.38k|    if (res.content_length_ == 0) {
  ------------------
  |  Branch (13100:9): [True: 0, False: 1.38k]
  ------------------
13101|      0|      if (res.is_chunked_content_provider_) {
  ------------------
  |  Branch (13101:11): [True: 0, False: 0]
  ------------------
13102|      0|        res.set_header("Transfer-Encoding", "chunked");
13103|      0|      } else if (req.method != "HEAD") {
  ------------------
  |  Branch (13103:18): [True: 0, False: 0]
  ------------------
13104|       |        // RFC 9112 6.3: a body with neither ends where the connection does.
13105|      0|        res.headers.erase("Keep-Alive");
13106|      0|        if (!has_header_token(res.headers, "Connection", "close")) {
  ------------------
  |  Branch (13106:13): [True: 0, False: 0]
  ------------------
13107|      0|          res.set_header("Connection", "close");
13108|      0|        }
13109|      0|      }
13110|      0|      return;
13111|      0|    }
13112|       |
13113|       |    // The part Server::write_content_with_provider() writes.
13114|  1.38k|    auto length = res.content_length_;
13115|  1.38k|    if (is_partial_content(req, res)) {
  ------------------
  |  Branch (13115:9): [True: 447, False: 935]
  ------------------
13116|    447|      length = req.ranges.size() == 1
  ------------------
  |  Branch (13116:16): [True: 362, False: 85]
  ------------------
13117|    447|                   ? get_range_offset_and_length(req.ranges[0], length).second
13118|    447|                   : get_multipart_ranges_data_length(req, boundary,
13119|     85|                                                      content_type, length);
13120|    447|    }
13121|  1.38k|    res.set_header("Content-Length", std::to_string(length));
13122|  4.28k|  } else if (!res.body.empty()) {
  ------------------
  |  Branch (13122:14): [True: 0, False: 4.28k]
  ------------------
13123|      0|    res.set_header("Content-Length", std::to_string(res.body.size()));
13124|  4.28k|  } else {
13125|  4.28k|    res.set_header("Content-Length", head_length.empty() ? "0" : head_length);
  ------------------
  |  Branch (13125:38): [True: 4.28k, False: 0]
  ------------------
13126|  4.28k|  }
13127|  5.67k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5eraseERKS8_:
 1371|  12.9k|  size_type erase(const std::string &key) {
 1372|  12.9k|    auto before = entries_.size();
 1373|  12.9k|    entries_.erase(std::remove_if(entries_.begin(), entries_.end(),
 1374|  12.9k|                                  [key](const value_type &entry) {
 1375|  12.9k|                                    return keys_equal(entry.first, key);
 1376|  12.9k|                                  }),
 1377|  12.9k|                   entries_.end());
 1378|  12.9k|    return before - entries_.size();
 1379|  12.9k|  }
_ZZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5eraseERKS8_ENKUlRKNS2_4pairIS8_S8_EEE_clESH_:
 1374|  24.7k|                                  [key](const value_type &entry) {
 1375|  24.7k|                                    return keys_equal(entry.first, key);
 1376|  24.7k|                                  }),
_ZN7httplib6detail18is_partial_contentERKNS_7RequestERKNS_8ResponseE:
13079|  2.63k|inline bool is_partial_content(const Request &req, const Response &res) {
13080|  2.63k|  return !req.ranges.empty() && res.status == StatusCode::PartialContent_206;
  ------------------
  |  Branch (13080:10): [True: 881, False: 1.75k]
  |  Branch (13080:33): [True: 881, False: 0]
  ------------------
13081|  2.63k|}
_ZN7httplib6detail32get_multipart_ranges_data_lengthERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEESC_m:
11151|     85|                                               size_t content_length) {
11152|     85|  size_t data_length = 0;
11153|       |
11154|     85|  process_multipart_ranges_data(
11155|     85|      req, boundary, content_type, content_length,
11156|     85|      [&](const std::string &token) { data_length += token.size(); },
11157|     85|      [&](const std::string &token) { data_length += token.size(); },
11158|     85|      [&](size_t /*offset*/, size_t length) {
11159|     85|        data_length += length;
11160|     85|        return true;
11161|     85|      });
11162|       |
11163|     85|  return data_length;
11164|     85|}
_ZN7httplib6detail29process_multipart_ranges_dataIZNS0_32get_multipart_ranges_data_lengthERKNS_7RequestERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEESD_mEUlSD_E_ZNS0_32get_multipart_ranges_data_lengthES4_SD_SD_mEUlSD_E0_ZNS0_32get_multipart_ranges_data_lengthES4_SD_SD_mEUlmmE_EEbS4_SD_SD_mT_T0_T1_:
11100|     85|                                   CToken ctoken, Content content) {
11101|    389|  for (size_t i = 0; i < req.ranges.size(); i++) {
  ------------------
  |  Branch (11101:22): [True: 304, False: 85]
  ------------------
11102|    304|    ctoken("--");
11103|    304|    stoken(boundary);
11104|    304|    ctoken("\r\n");
11105|    304|    if (!content_type.empty()) {
  ------------------
  |  Branch (11105:9): [True: 304, False: 0]
  ------------------
11106|    304|      ctoken("Content-Type: ");
11107|    304|      stoken(content_type);
11108|    304|      ctoken("\r\n");
11109|    304|    }
11110|       |
11111|    304|    auto offset_and_length =
11112|    304|        get_range_offset_and_length(req.ranges[i], content_length);
11113|       |
11114|    304|    ctoken("Content-Range: ");
11115|    304|    stoken(make_content_range_header_field(offset_and_length, content_length));
11116|    304|    ctoken("\r\n");
11117|    304|    ctoken("\r\n");
11118|       |
11119|    304|    if (!content(offset_and_length.first, offset_and_length.second)) {
  ------------------
  |  Branch (11119:9): [True: 0, False: 304]
  ------------------
11120|      0|      return false;
11121|      0|    }
11122|    304|    ctoken("\r\n");
11123|    304|  }
11124|       |
11125|     85|  ctoken("--");
11126|     85|  stoken(boundary);
11127|     85|  ctoken("--");
11128|       |
11129|     85|  return true;
11130|     85|}
_ZZN7httplib6detail32get_multipart_ranges_data_lengthERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEESC_mENKUlSC_E0_clESC_:
11157|  2.60k|      [&](const std::string &token) { data_length += token.size(); },
_ZZN7httplib6detail32get_multipart_ranges_data_lengthERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEESC_mENKUlSC_E_clESC_:
11156|    997|      [&](const std::string &token) { data_length += token.size(); },
_ZZN7httplib6detail32get_multipart_ranges_data_lengthERKNS_7RequestERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEESC_mENKUlmmE_clEmm:
11158|    304|      [&](size_t /*offset*/, size_t length) {
11159|    304|        data_length += length;
11160|    304|        return true;
11161|    304|      });
_ZN7httplib6detail12BufferStreamC2Ev:
 4110|  5.71k|  BufferStream() = default;
_ZN7httplib6detail19write_response_lineERNS_6StreamEi:
 9692|  5.71k|inline ssize_t write_response_line(Stream &strm, int status) {
 9693|  5.71k|  std::string s = "HTTP/1.1 ";
 9694|  5.71k|  s += std::to_string(status);
 9695|  5.71k|  s += ' ';
 9696|  5.71k|  s += httplib::status_message(status);
 9697|  5.71k|  s += "\r\n";
 9698|  5.71k|  return strm.write(s.data(), s.size());
 9699|  5.71k|}
_ZN7httplib14status_messageEi:
12359|  5.71k|inline const char *status_message(int status) {
12360|  5.71k|  switch (status) {
12361|      0|  case StatusCode::Continue_100: return "Continue";
  ------------------
  |  Branch (12361:3): [True: 0, False: 5.71k]
  ------------------
12362|      0|  case StatusCode::SwitchingProtocol_101: return "Switching Protocol";
  ------------------
  |  Branch (12362:3): [True: 0, False: 5.71k]
  ------------------
12363|      0|  case StatusCode::Processing_102: return "Processing";
  ------------------
  |  Branch (12363:3): [True: 0, False: 5.71k]
  ------------------
12364|      0|  case StatusCode::EarlyHints_103: return "Early Hints";
  ------------------
  |  Branch (12364:3): [True: 0, False: 5.71k]
  ------------------
12365|    935|  case StatusCode::OK_200: return "OK";
  ------------------
  |  Branch (12365:3): [True: 935, False: 4.78k]
  ------------------
12366|      0|  case StatusCode::Created_201: return "Created";
  ------------------
  |  Branch (12366:3): [True: 0, False: 5.71k]
  ------------------
12367|      0|  case StatusCode::Accepted_202: return "Accepted";
  ------------------
  |  Branch (12367:3): [True: 0, False: 5.71k]
  ------------------
12368|      0|  case StatusCode::NonAuthoritativeInformation_203:
  ------------------
  |  Branch (12368:3): [True: 0, False: 5.71k]
  ------------------
12369|      0|    return "Non-Authoritative Information";
12370|      0|  case StatusCode::NoContent_204: return "No Content";
  ------------------
  |  Branch (12370:3): [True: 0, False: 5.71k]
  ------------------
12371|      0|  case StatusCode::ResetContent_205: return "Reset Content";
  ------------------
  |  Branch (12371:3): [True: 0, False: 5.71k]
  ------------------
12372|    447|  case StatusCode::PartialContent_206: return "Partial Content";
  ------------------
  |  Branch (12372:3): [True: 447, False: 5.27k]
  ------------------
12373|      0|  case StatusCode::MultiStatus_207: return "Multi-Status";
  ------------------
  |  Branch (12373:3): [True: 0, False: 5.71k]
  ------------------
12374|      0|  case StatusCode::AlreadyReported_208: return "Already Reported";
  ------------------
  |  Branch (12374:3): [True: 0, False: 5.71k]
  ------------------
12375|      0|  case StatusCode::IMUsed_226: return "IM Used";
  ------------------
  |  Branch (12375:3): [True: 0, False: 5.71k]
  ------------------
12376|      0|  case StatusCode::MultipleChoices_300: return "Multiple Choices";
  ------------------
  |  Branch (12376:3): [True: 0, False: 5.71k]
  ------------------
12377|      6|  case StatusCode::MovedPermanently_301: return "Moved Permanently";
  ------------------
  |  Branch (12377:3): [True: 6, False: 5.71k]
  ------------------
12378|      0|  case StatusCode::Found_302: return "Found";
  ------------------
  |  Branch (12378:3): [True: 0, False: 5.71k]
  ------------------
12379|      0|  case StatusCode::SeeOther_303: return "See Other";
  ------------------
  |  Branch (12379:3): [True: 0, False: 5.71k]
  ------------------
12380|     46|  case StatusCode::NotModified_304: return "Not Modified";
  ------------------
  |  Branch (12380:3): [True: 46, False: 5.67k]
  ------------------
12381|      0|  case StatusCode::UseProxy_305: return "Use Proxy";
  ------------------
  |  Branch (12381:3): [True: 0, False: 5.71k]
  ------------------
12382|      0|  case StatusCode::unused_306: return "unused";
  ------------------
  |  Branch (12382:3): [True: 0, False: 5.71k]
  ------------------
12383|      0|  case StatusCode::TemporaryRedirect_307: return "Temporary Redirect";
  ------------------
  |  Branch (12383:3): [True: 0, False: 5.71k]
  ------------------
12384|      0|  case StatusCode::PermanentRedirect_308: return "Permanent Redirect";
  ------------------
  |  Branch (12384:3): [True: 0, False: 5.71k]
  ------------------
12385|  2.27k|  case StatusCode::BadRequest_400: return "Bad Request";
  ------------------
  |  Branch (12385:3): [True: 2.27k, False: 3.44k]
  ------------------
12386|      0|  case StatusCode::Unauthorized_401: return "Unauthorized";
  ------------------
  |  Branch (12386:3): [True: 0, False: 5.71k]
  ------------------
12387|      0|  case StatusCode::PaymentRequired_402: return "Payment Required";
  ------------------
  |  Branch (12387:3): [True: 0, False: 5.71k]
  ------------------
12388|      4|  case StatusCode::Forbidden_403: return "Forbidden";
  ------------------
  |  Branch (12388:3): [True: 4, False: 5.71k]
  ------------------
12389|  1.63k|  case StatusCode::NotFound_404: return "Not Found";
  ------------------
  |  Branch (12389:3): [True: 1.63k, False: 4.07k]
  ------------------
12390|      0|  case StatusCode::MethodNotAllowed_405: return "Method Not Allowed";
  ------------------
  |  Branch (12390:3): [True: 0, False: 5.71k]
  ------------------
12391|      0|  case StatusCode::NotAcceptable_406: return "Not Acceptable";
  ------------------
  |  Branch (12391:3): [True: 0, False: 5.71k]
  ------------------
12392|      0|  case StatusCode::ProxyAuthenticationRequired_407:
  ------------------
  |  Branch (12392:3): [True: 0, False: 5.71k]
  ------------------
12393|      0|    return "Proxy Authentication Required";
12394|      0|  case StatusCode::RequestTimeout_408: return "Request Timeout";
  ------------------
  |  Branch (12394:3): [True: 0, False: 5.71k]
  ------------------
12395|      0|  case StatusCode::Conflict_409: return "Conflict";
  ------------------
  |  Branch (12395:3): [True: 0, False: 5.71k]
  ------------------
12396|      0|  case StatusCode::Gone_410: return "Gone";
  ------------------
  |  Branch (12396:3): [True: 0, False: 5.71k]
  ------------------
12397|      0|  case StatusCode::LengthRequired_411: return "Length Required";
  ------------------
  |  Branch (12397:3): [True: 0, False: 5.71k]
  ------------------
12398|      0|  case StatusCode::PreconditionFailed_412: return "Precondition Failed";
  ------------------
  |  Branch (12398:3): [True: 0, False: 5.71k]
  ------------------
12399|      0|  case StatusCode::PayloadTooLarge_413: return "Payload Too Large";
  ------------------
  |  Branch (12399:3): [True: 0, False: 5.71k]
  ------------------
12400|      3|  case StatusCode::UriTooLong_414: return "URI Too Long";
  ------------------
  |  Branch (12400:3): [True: 3, False: 5.71k]
  ------------------
12401|      0|  case StatusCode::UnsupportedMediaType_415: return "Unsupported Media Type";
  ------------------
  |  Branch (12401:3): [True: 0, False: 5.71k]
  ------------------
12402|    362|  case StatusCode::RangeNotSatisfiable_416: return "Range Not Satisfiable";
  ------------------
  |  Branch (12402:3): [True: 362, False: 5.35k]
  ------------------
12403|      0|  case StatusCode::ExpectationFailed_417: return "Expectation Failed";
  ------------------
  |  Branch (12403:3): [True: 0, False: 5.71k]
  ------------------
12404|      0|  case StatusCode::ImATeapot_418: return "I'm a teapot";
  ------------------
  |  Branch (12404:3): [True: 0, False: 5.71k]
  ------------------
12405|      0|  case StatusCode::MisdirectedRequest_421: return "Misdirected Request";
  ------------------
  |  Branch (12405:3): [True: 0, False: 5.71k]
  ------------------
12406|      0|  case StatusCode::UnprocessableContent_422: return "Unprocessable Content";
  ------------------
  |  Branch (12406:3): [True: 0, False: 5.71k]
  ------------------
12407|      0|  case StatusCode::Locked_423: return "Locked";
  ------------------
  |  Branch (12407:3): [True: 0, False: 5.71k]
  ------------------
12408|      0|  case StatusCode::FailedDependency_424: return "Failed Dependency";
  ------------------
  |  Branch (12408:3): [True: 0, False: 5.71k]
  ------------------
12409|      0|  case StatusCode::TooEarly_425: return "Too Early";
  ------------------
  |  Branch (12409:3): [True: 0, False: 5.71k]
  ------------------
12410|      0|  case StatusCode::UpgradeRequired_426: return "Upgrade Required";
  ------------------
  |  Branch (12410:3): [True: 0, False: 5.71k]
  ------------------
12411|      0|  case StatusCode::PreconditionRequired_428: return "Precondition Required";
  ------------------
  |  Branch (12411:3): [True: 0, False: 5.71k]
  ------------------
12412|      0|  case StatusCode::TooManyRequests_429: return "Too Many Requests";
  ------------------
  |  Branch (12412:3): [True: 0, False: 5.71k]
  ------------------
12413|      0|  case StatusCode::RequestHeaderFieldsTooLarge_431:
  ------------------
  |  Branch (12413:3): [True: 0, False: 5.71k]
  ------------------
12414|      0|    return "Request Header Fields Too Large";
12415|      0|  case StatusCode::UnavailableForLegalReasons_451:
  ------------------
  |  Branch (12415:3): [True: 0, False: 5.71k]
  ------------------
12416|      0|    return "Unavailable For Legal Reasons";
12417|      0|  case StatusCode::NotImplemented_501: return "Not Implemented";
  ------------------
  |  Branch (12417:3): [True: 0, False: 5.71k]
  ------------------
12418|      0|  case StatusCode::BadGateway_502: return "Bad Gateway";
  ------------------
  |  Branch (12418:3): [True: 0, False: 5.71k]
  ------------------
12419|      0|  case StatusCode::ServiceUnavailable_503: return "Service Unavailable";
  ------------------
  |  Branch (12419:3): [True: 0, False: 5.71k]
  ------------------
12420|      0|  case StatusCode::GatewayTimeout_504: return "Gateway Timeout";
  ------------------
  |  Branch (12420:3): [True: 0, False: 5.71k]
  ------------------
12421|      0|  case StatusCode::HttpVersionNotSupported_505:
  ------------------
  |  Branch (12421:3): [True: 0, False: 5.71k]
  ------------------
12422|      0|    return "HTTP Version Not Supported";
12423|      0|  case StatusCode::VariantAlsoNegotiates_506: return "Variant Also Negotiates";
  ------------------
  |  Branch (12423:3): [True: 0, False: 5.71k]
  ------------------
12424|      0|  case StatusCode::InsufficientStorage_507: return "Insufficient Storage";
  ------------------
  |  Branch (12424:3): [True: 0, False: 5.71k]
  ------------------
12425|      0|  case StatusCode::LoopDetected_508: return "Loop Detected";
  ------------------
  |  Branch (12425:3): [True: 0, False: 5.71k]
  ------------------
12426|      0|  case StatusCode::NotExtended_510: return "Not Extended";
  ------------------
  |  Branch (12426:3): [True: 0, False: 5.71k]
  ------------------
12427|      0|  case StatusCode::NetworkAuthenticationRequired_511:
  ------------------
  |  Branch (12427:3): [True: 0, False: 5.71k]
  ------------------
12428|      0|    return "Network Authentication Required";
12429|       |
12430|      0|  default:
  ------------------
  |  Branch (12430:3): [True: 0, False: 5.71k]
  ------------------
12431|      0|  case StatusCode::InternalServerError_500: return "Internal Server Error";
  ------------------
  |  Branch (12431:3): [True: 0, False: 5.71k]
  ------------------
12432|  5.71k|  }
12433|  5.71k|}
_ZN7httplib6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEESG_:
15304|  1.25k|                                    const std::string &content_type) {
15305|  1.25k|  auto is_shutting_down = [this]() { return is_stopping(); };
15306|       |
15307|  1.25k|  if (res.content_length_ > 0) {
  ------------------
  |  Branch (15307:7): [True: 1.25k, False: 0]
  ------------------
15308|  1.25k|    if (!detail::is_partial_content(req, res)) {
  ------------------
  |  Branch (15308:9): [True: 819, False: 434]
  ------------------
15309|    819|      return detail::write_content(strm, res.content_provider_, 0,
15310|    819|                                   res.content_length_, is_shutting_down);
15311|    819|    } else if (req.ranges.size() == 1) {
  ------------------
  |  Branch (15311:16): [True: 352, False: 82]
  ------------------
15312|    352|      auto offset_and_length = detail::get_range_offset_and_length(
15313|    352|          req.ranges[0], res.content_length_);
15314|       |
15315|    352|      return detail::write_content(strm, res.content_provider_,
15316|    352|                                   offset_and_length.first,
15317|    352|                                   offset_and_length.second, is_shutting_down);
15318|    352|    } else {
15319|     82|      return detail::write_multipart_ranges_data(
15320|     82|          strm, req, res, boundary, content_type, res.content_length_,
15321|     82|          is_shutting_down);
15322|     82|    }
15323|  1.25k|  } else {
15324|      0|    if (res.is_chunked_content_provider_) {
  ------------------
  |  Branch (15324:9): [True: 0, False: 0]
  ------------------
15325|       |      // Use the coding `apply_ranges()` chose when it wrote the headers;
15326|       |      // re-negotiating here would disagree with them, e.g. once a handler's
15327|       |      // own Content-Encoding header suppresses the negotiation.
15328|      0|      auto compressor = detail::make_compressor(res.content_coding_);
15329|      0|      if (!compressor) {
  ------------------
  |  Branch (15329:11): [True: 0, False: 0]
  ------------------
15330|      0|        compressor = detail::make_unique<detail::nocompressor>();
15331|      0|      }
15332|       |
15333|      0|      return detail::write_content_chunked(strm, res.content_provider_,
15334|      0|                                           is_shutting_down, *compressor);
15335|      0|    } else {
15336|      0|      return detail::write_content_without_length(strm, res.content_provider_,
15337|      0|                                                  is_shutting_down);
15338|      0|    }
15339|      0|  }
15340|  1.25k|}
_ZN7httplib6detail13write_contentIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_RKNSA_8functionIFbmmRNS_8DataSinkEEEEmmRKT_:
 9819|  1.46k|                          const T &is_shutting_down) {
 9820|  1.46k|  auto error = Error::Success;
 9821|  1.46k|  return write_content(strm, content_provider, offset, length, is_shutting_down,
 9822|  1.46k|                       error);
 9823|  1.46k|}
_ZN7httplib6detail13write_contentIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_RKNSA_8functionIFbmmRNS_8DataSinkEEEEmmT_RNS_5ErrorE:
 9811|  1.46k|                          Error &error) {
 9812|  1.46k|  return write_content_with_progress<T>(strm, content_provider, offset, length,
 9813|  1.46k|                                        is_shutting_down, nullptr, error);
 9814|  1.46k|}
_ZN7httplib6detail27write_content_with_progressIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_RKNSA_8functionIFbmmRNS_8DataSinkEEEEmmT_RKNSK_IFbmmEEERNS_5ErrorE:
 9736|  1.46k|                                        Error &error) {
 9737|  1.46k|  size_t end_offset = offset + length;
 9738|  1.46k|  size_t start_offset = offset;
 9739|  1.46k|  auto ok = true;
 9740|  1.46k|  auto finished = false;
 9741|  1.46k|  DataSink data_sink;
 9742|       |
 9743|  1.46k|  data_sink.write = [&](const char *d, size_t l) -> bool {
 9744|  1.46k|    if (ok) {
 9745|       |      // Bytes past `length` would follow the framed body, where the peer reads
 9746|       |      // them as the next message. Write only what fits and fail the rest.
 9747|  1.46k|      if (l > end_offset - offset) {
 9748|  1.46k|        l = end_offset - offset;
 9749|  1.46k|        ok = false;
 9750|  1.46k|      }
 9751|  1.46k|      if (write_data(strm, d, l)) {
 9752|  1.46k|        offset += l;
 9753|       |
 9754|  1.46k|        if (upload_progress && length > 0) {
 9755|  1.46k|          size_t current_written = offset - start_offset;
 9756|  1.46k|          if (!upload_progress(current_written, length)) {
 9757|  1.46k|            ok = false;
 9758|  1.46k|            return false;
 9759|  1.46k|          }
 9760|  1.46k|        }
 9761|  1.46k|      } else {
 9762|  1.46k|        ok = false;
 9763|  1.46k|      }
 9764|  1.46k|    }
 9765|  1.46k|    return ok;
 9766|  1.46k|  };
 9767|       |
 9768|  1.46k|  data_sink.is_writable = [&]() -> bool { return strm.is_peer_alive(); };
 9769|       |
 9770|       |  // The body is framed by `length`, so a provider that reports itself done
 9771|       |  // early has truncated it. Record that and let the short-body check below
 9772|       |  // fail the write, rather than calling the provider again forever.
 9773|  1.46k|  data_sink.done = [&]() { finished = true; };
 9774|       |
 9775|  2.93k|  while (offset < end_offset && !finished && !is_shutting_down()) {
  ------------------
  |  Branch (9775:10): [True: 1.46k, False: 1.46k]
  |  Branch (9775:33): [True: 1.46k, False: 0]
  |  Branch (9775:46): [True: 1.46k, False: 0]
  ------------------
 9776|  1.46k|    auto last_offset = offset;
 9777|       |
 9778|  1.46k|    if (!strm.wait_writable() || !strm.is_peer_alive()) {
  ------------------
  |  Branch (9778:9): [True: 0, False: 1.46k]
  |  Branch (9778:34): [True: 0, False: 1.46k]
  ------------------
 9779|      0|      error = Error::Write;
 9780|      0|      return false;
 9781|  1.46k|    } else if (!content_provider(offset, end_offset - offset, data_sink)) {
  ------------------
  |  Branch (9781:16): [True: 0, False: 1.46k]
  ------------------
 9782|      0|      error = Error::Canceled;
 9783|      0|      return false;
 9784|  1.46k|    } else if (!ok) {
  ------------------
  |  Branch (9784:16): [True: 0, False: 1.46k]
  ------------------
 9785|      0|      error = Error::Write;
 9786|      0|      return false;
 9787|      0|    }
 9788|       |
 9789|       |    // A provider that reports success without writing anything and without
 9790|       |    // reporting itself done gets handed the same offset and length again on
 9791|       |    // the next pass, so it would spin here for as long as the peer stays
 9792|       |    // connected. Treat making no progress as a short body, like done() early.
 9793|  1.46k|    if (!finished && offset == last_offset) {
  ------------------
  |  Branch (9793:9): [True: 1.46k, False: 0]
  |  Branch (9793:22): [True: 0, False: 1.46k]
  ------------------
 9794|      0|      error = Error::Write;
 9795|      0|      return false;
 9796|      0|    }
 9797|  1.46k|  }
 9798|       |
 9799|  1.46k|  if (offset < end_offset) { // done() called early, or is_shutting_down()
  ------------------
  |  Branch (9799:7): [True: 0, False: 1.46k]
  ------------------
 9800|      0|    error = Error::Write;
 9801|      0|    return false;
 9802|      0|  }
 9803|       |
 9804|  1.46k|  error = Error::Success;
 9805|  1.46k|  return true;
 9806|  1.46k|}
_ZZN7httplib6detail27write_content_with_progressIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_RKNSA_8functionIFbmmRNS_8DataSinkEEEEmmT_RKNSK_IFbmmEEERNS_5ErrorEENKUlPKcmE_clESZ_m:
 9743|  1.46k|  data_sink.write = [&](const char *d, size_t l) -> bool {
 9744|  1.46k|    if (ok) {
  ------------------
  |  Branch (9744:9): [True: 1.46k, False: 0]
  ------------------
 9745|       |      // Bytes past `length` would follow the framed body, where the peer reads
 9746|       |      // them as the next message. Write only what fits and fail the rest.
 9747|  1.46k|      if (l > end_offset - offset) {
  ------------------
  |  Branch (9747:11): [True: 0, False: 1.46k]
  ------------------
 9748|      0|        l = end_offset - offset;
 9749|      0|        ok = false;
 9750|      0|      }
 9751|  1.46k|      if (write_data(strm, d, l)) {
  ------------------
  |  Branch (9751:11): [True: 1.46k, False: 0]
  ------------------
 9752|  1.46k|        offset += l;
 9753|       |
 9754|  1.46k|        if (upload_progress && length > 0) {
  ------------------
  |  Branch (9754:13): [True: 0, False: 1.46k]
  |  Branch (9754:32): [True: 0, False: 0]
  ------------------
 9755|      0|          size_t current_written = offset - start_offset;
 9756|      0|          if (!upload_progress(current_written, length)) {
  ------------------
  |  Branch (9756:15): [True: 0, False: 0]
  ------------------
 9757|      0|            ok = false;
 9758|      0|            return false;
 9759|      0|          }
 9760|      0|        }
 9761|  1.46k|      } else {
 9762|      0|        ok = false;
 9763|      0|      }
 9764|  1.46k|    }
 9765|  1.46k|    return ok;
 9766|  1.46k|  };
_ZZN7httplib6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEESG_ENKUlvE_clEv:
15305|  1.46k|  auto is_shutting_down = [this]() { return is_stopping(); };
_ZNK7httplib6Server11is_stoppingEv:
 2485|  1.46k|  bool is_stopping() const { return svr_sock_ == INVALID_SOCKET; }
  ------------------
  |  |  395|  1.46k|#define INVALID_SOCKET (-1)
  ------------------
_ZN7httplib6detail27write_multipart_ranges_dataIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_S7_S9_SI_SI_mRKT_:
11171|     82|                            size_t content_length, const T &is_shutting_down) {
11172|     82|  return process_multipart_ranges_data(
11173|     82|      req, boundary, content_type, content_length,
11174|     82|      [&](const std::string &token) { strm.write(token); },
11175|     82|      [&](const std::string &token) { strm.write(token); },
11176|     82|      [&](size_t offset, size_t length) {
11177|     82|        return write_content(strm, res.content_provider_, offset, length,
11178|     82|                             is_shutting_down);
11179|     82|      });
11180|     82|}
_ZN7httplib6detail29process_multipart_ranges_dataIZNS0_27write_multipart_ranges_dataIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSB_11char_traitsIcEENSB_9allocatorIcEEEESJ_EUlvE_EEbS5_S8_SA_SJ_SJ_mRKT_EUlSJ_E_ZNS2_ISK_EEbS5_S8_SA_SJ_SJ_mSN_EUlSJ_E0_ZNS2_ISK_EEbS5_S8_SA_SJ_SJ_mSN_EUlmmE_EEbS8_SJ_SJ_mSL_T0_T1_:
11100|     82|                                   CToken ctoken, Content content) {
11101|    379|  for (size_t i = 0; i < req.ranges.size(); i++) {
  ------------------
  |  Branch (11101:22): [True: 297, False: 82]
  ------------------
11102|    297|    ctoken("--");
11103|    297|    stoken(boundary);
11104|    297|    ctoken("\r\n");
11105|    297|    if (!content_type.empty()) {
  ------------------
  |  Branch (11105:9): [True: 297, False: 0]
  ------------------
11106|    297|      ctoken("Content-Type: ");
11107|    297|      stoken(content_type);
11108|    297|      ctoken("\r\n");
11109|    297|    }
11110|       |
11111|    297|    auto offset_and_length =
11112|    297|        get_range_offset_and_length(req.ranges[i], content_length);
11113|       |
11114|    297|    ctoken("Content-Range: ");
11115|    297|    stoken(make_content_range_header_field(offset_and_length, content_length));
11116|    297|    ctoken("\r\n");
11117|    297|    ctoken("\r\n");
11118|       |
11119|    297|    if (!content(offset_and_length.first, offset_and_length.second)) {
  ------------------
  |  Branch (11119:9): [True: 0, False: 297]
  ------------------
11120|      0|      return false;
11121|      0|    }
11122|    297|    ctoken("\r\n");
11123|    297|  }
11124|       |
11125|     82|  ctoken("--");
11126|     82|  stoken(boundary);
11127|     82|  ctoken("--");
11128|       |
11129|     82|  return true;
11130|     82|}
_ZZN7httplib6detail27write_multipart_ranges_dataIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_S7_S9_SI_SI_mRKT_ENKUlSI_E0_clESI_:
11175|  2.54k|      [&](const std::string &token) { strm.write(token); },
_ZN7httplib6Stream5writeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
13266|  3.51k|inline ssize_t Stream::write(const std::string &s) {
13267|  3.51k|  return write(s.data(), s.size());
13268|  3.51k|}
_ZZN7httplib6detail27write_multipart_ranges_dataIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_S7_S9_SI_SI_mRKT_ENKUlSI_E_clESI_:
11174|    973|      [&](const std::string &token) { strm.write(token); },
_ZZN7httplib6detail27write_multipart_ranges_dataIZNS_6Server27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEESI_EUlvE_EEbS4_S7_S9_SI_SI_mRKT_ENKUlmmE_clEmm:
11176|    297|      [&](size_t offset, size_t length) {
11177|    297|        return write_content(strm, res.content_provider_, offset, length,
11178|    297|                             is_shutting_down);
11179|    297|      });
_ZN7httplib6detail13from_i_to_hexEm:
 5813|  3.18k|inline std::string from_i_to_hex(size_t n) {
 5814|  3.18k|  static const auto charset = "0123456789abcdef";
 5815|  3.18k|  std::string ret;
 5816|  15.9k|  do {
 5817|  15.9k|    ret = charset[n & 15] + ret;
 5818|  15.9k|    n >>= 4;
 5819|  15.9k|  } while (n > 0);
  ------------------
  |  Branch (5819:12): [True: 12.7k, False: 3.18k]
  ------------------
 5820|  3.18k|  return ret;
 5821|  3.18k|}
_ZNK7httplib6Server10output_logERKNS_7RequestERKNS_8ResponseE:
16804|  5.71k|inline void Server::output_log(const Request &req, const Response &res) const {
16805|  5.71k|  if (logger_) {
  ------------------
  |  Branch (16805:7): [True: 0, False: 5.71k]
  ------------------
16806|      0|    std::lock_guard<std::mutex> guard(logger_mutex_);
16807|      0|    logger_(req, res);
16808|      0|  }
16809|  5.71k|}
_ZNK7httplib6detail12BufferStream10get_bufferEv:
13722|  5.71k|inline const std::string &BufferStream::get_buffer() const { return buffer; }
_ZN7httplib6detail10write_dataERNS_6StreamEPKcm:
 9720|  7.18k|inline bool write_data(Stream &strm, const char *d, size_t l) {
 9721|  7.18k|  size_t offset = 0;
 9722|  14.3k|  while (offset < l) {
  ------------------
  |  Branch (9722:10): [True: 7.18k, False: 7.18k]
  ------------------
 9723|  7.18k|    auto length = strm.write(d + offset, l - offset);
 9724|  7.18k|    if (length < 0) { return false; }
  ------------------
  |  Branch (9724:9): [True: 0, False: 7.18k]
  ------------------
 9725|  7.18k|    offset += static_cast<size_t>(length);
 9726|  7.18k|  }
 9727|  7.18k|  return true;
 9728|  7.18k|}
_ZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9227|  5.40k|inline bool read_headers(Stream &strm, Headers &headers) {
 9228|  5.40k|  const auto bufsiz = 2048;
 9229|  5.40k|  char buf[bufsiz];
 9230|  5.40k|  stream_line_reader line_reader(strm, buf, bufsiz);
 9231|       |
 9232|  5.40k|  size_t header_count = 0;
 9233|       |
 9234|  21.4k|  for (;;) {
 9235|  21.4k|    if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (9235:9): [True: 953, False: 20.5k]
  ------------------
 9236|       |
 9237|       |    // Check if the line ends with CRLF.
 9238|  20.5k|    auto line_terminator_len = 2;
 9239|  20.5k|    if (line_reader.end_with_crlf()) {
  ------------------
  |  Branch (9239:9): [True: 20.3k, False: 191]
  ------------------
 9240|       |      // Blank line indicates end of headers.
 9241|  20.3k|      if (line_reader.size() == 2) { break; }
  ------------------
  |  Branch (9241:11): [True: 4.14k, False: 16.1k]
  ------------------
 9242|  20.3k|    } else {
 9243|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 9244|       |      // Blank line indicates end of headers.
 9245|       |      if (line_reader.size() == 1) { break; }
 9246|       |      line_terminator_len = 1;
 9247|       |#else
 9248|    191|      continue; // Skip invalid line.
 9249|    191|#endif
 9250|    191|    }
 9251|       |
 9252|  16.1k|    if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
  ------------------
  |  |  127|  16.1k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (9252:9): [True: 6, False: 16.1k]
  ------------------
 9253|       |
 9254|       |    // Check header count limit
 9255|  16.1k|    if (header_count >= CPPHTTPLIB_HEADER_MAX_COUNT) { return false; }
  ------------------
  |  |  131|  16.1k|#define CPPHTTPLIB_HEADER_MAX_COUNT 100
  ------------------
  |  Branch (9255:9): [True: 2, False: 16.1k]
  ------------------
 9256|       |
 9257|       |    // Exclude line terminator
 9258|  16.1k|    auto end = line_reader.ptr() + line_reader.size() - line_terminator_len;
 9259|       |
 9260|  16.1k|    if (!parse_header(line_reader.ptr(), end,
  ------------------
  |  Branch (9260:9): [True: 298, False: 15.8k]
  ------------------
 9261|  16.1k|                      [&](const std::string &key, const std::string &val) {
 9262|  16.1k|                        headers.emplace(key, val);
 9263|  16.1k|                      })) {
 9264|    298|      return false;
 9265|    298|    }
 9266|       |
 9267|  15.8k|    header_count++;
 9268|  15.8k|  }
 9269|       |
 9270|       |  // RFC 9110 Section 8.6: Reject requests with multiple Content-Length
 9271|       |  // headers that have different values to prevent request smuggling.
 9272|  4.14k|  auto cl_range = headers.equal_range("Content-Length");
 9273|  4.14k|  if (cl_range.first != cl_range.second) {
  ------------------
  |  Branch (9273:7): [True: 654, False: 3.49k]
  ------------------
 9274|    654|    const auto &first_val = cl_range.first->second;
 9275|    913|    for (auto it = std::next(cl_range.first); it != cl_range.second; ++it) {
  ------------------
  |  Branch (9275:47): [True: 289, False: 624]
  ------------------
 9276|    289|      if (it->second != first_val) { return false; }
  ------------------
  |  Branch (9276:11): [True: 30, False: 259]
  ------------------
 9277|    289|    }
 9278|    654|  }
 9279|       |
 9280|  4.11k|  return true;
 9281|  4.14k|}
_ZNK7httplib6detail18stream_line_reader13end_with_crlfEv:
 6868|  20.5k|inline bool stream_line_reader::end_with_crlf() const {
 6869|  20.5k|  auto end = ptr() + size();
 6870|  20.5k|  return size() >= 2 && end[-2] == '\r' && end[-1] == '\n';
  ------------------
  |  Branch (6870:10): [True: 20.4k, False: 64]
  |  Branch (6870:25): [True: 20.3k, False: 100]
  |  Branch (6870:44): [True: 20.3k, False: 27]
  ------------------
 6871|  20.5k|}
_ZN7httplib6detail12parse_headerIZNS0_12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS0_11case_ignore8equal_toEEEEUlRKSB_SH_E_EEbPKcSK_T_:
 6531|  16.1k|inline bool parse_header(const char *beg, const char *end, T fn) {
 6532|       |  // Skip trailing spaces and tabs.
 6533|  16.4k|  while (beg < end && is_space_or_tab(end[-1])) {
  ------------------
  |  Branch (6533:10): [True: 16.4k, False: 9]
  |  Branch (6533:23): [True: 253, False: 16.1k]
  ------------------
 6534|    253|    end--;
 6535|    253|  }
 6536|       |
 6537|  16.1k|  auto p = beg;
 6538|   196k|  while (p < end && *p != ':') {
  ------------------
  |  Branch (6538:10): [True: 196k, False: 242]
  |  Branch (6538:21): [True: 180k, False: 15.9k]
  ------------------
 6539|   180k|    p++;
 6540|   180k|  }
 6541|       |
 6542|  16.1k|  auto name = std::string(beg, p);
 6543|  16.1k|  if (!detail::fields::is_field_name(name)) { return false; }
  ------------------
  |  Branch (6543:7): [True: 113, False: 16.0k]
  ------------------
 6544|       |
 6545|  16.0k|  if (p == end) { return false; }
  ------------------
  |  Branch (6545:7): [True: 138, False: 15.9k]
  ------------------
 6546|       |
 6547|  15.9k|  auto key_end = p;
 6548|       |
 6549|  15.9k|  if (*p++ != ':') { return false; }
  ------------------
  |  Branch (6549:7): [True: 0, False: 15.9k]
  ------------------
 6550|       |
 6551|  18.2k|  while (p < end && is_space_or_tab(*p)) {
  ------------------
  |  Branch (6551:10): [True: 14.1k, False: 4.15k]
  |  Branch (6551:21): [True: 2.34k, False: 11.7k]
  ------------------
 6552|  2.34k|    p++;
 6553|  2.34k|  }
 6554|       |
 6555|  15.9k|  if (p <= end) {
  ------------------
  |  Branch (6555:7): [True: 15.9k, False: 0]
  ------------------
 6556|  15.9k|    auto key_len = key_end - beg;
 6557|  15.9k|    if (!key_len) { return false; }
  ------------------
  |  Branch (6557:9): [True: 0, False: 15.9k]
  ------------------
 6558|       |
 6559|  15.9k|    auto key = std::string(beg, key_end);
 6560|  15.9k|    auto val = std::string(p, end);
 6561|       |
 6562|  15.9k|    if (!detail::fields::is_field_value(val)) { return false; }
  ------------------
  |  Branch (6562:9): [True: 47, False: 15.8k]
  ------------------
 6563|       |
 6564|       |    // RFC 9110 §5.5: header field values are opaque octets and MUST NOT be
 6565|       |    // percent-decoded by the recipient. Applications that need to interpret a
 6566|       |    // value as a URI component should call httplib::decode_uri_component()
 6567|       |    // (or decode_path_component()) explicitly.
 6568|  15.8k|    fn(key, val);
 6569|       |
 6570|  15.8k|    return true;
 6571|  15.9k|  }
 6572|       |
 6573|      0|  return false;
 6574|  15.9k|}
_ZZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEEENKUlRKSA_SG_E_clESG_SG_:
 9261|  15.8k|                      [&](const std::string &key, const std::string &val) {
 9262|  15.8k|                        headers.emplace(key, val);
 9263|  15.8k|                      })) {
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1358|  4.14k|  std::pair<iterator, iterator> equal_range(const std::string &key) {
 1359|  4.14k|    auto i = index_of(key);
 1360|  4.14k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1360:12): [True: 3.49k, False: 654]
  ------------------
 1361|  4.14k|                       : std::make_pair(make_iter(i, i), end());
 1362|  4.14k|  }
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mmRb:
 3714|  9.34k|                                   size_t id, bool &is_invalid_value) {
 3715|  9.34k|  is_invalid_value = false;
 3716|  9.34k|  auto rng = headers.equal_range(key);
 3717|  9.34k|  auto it = bounded_next(rng.first, id, rng.second);
 3718|  9.34k|  if (it != rng.second) {
  ------------------
  |  Branch (3718:7): [True: 1.68k, False: 7.66k]
  ------------------
 3719|  1.68k|    if (is_numeric(it->second)) {
  ------------------
  |  Branch (3719:9): [True: 1.65k, False: 23]
  ------------------
 3720|       |      // Parse at size_t width so an out-of-range Content-Length is reported
 3721|       |      // rather than silently saturated/truncated (a value above 2^32 would
 3722|       |      // otherwise wrap to a small framing length on 32-bit builds). Flag it
 3723|       |      // and return SIZE_MAX so the existing oversized-value guards reject it.
 3724|  1.65k|      size_t val = 0;
 3725|  1.65k|      const auto &s = it->second;
 3726|  1.65k|      auto r = from_chars(s.data(), s.data() + s.size(), val);
 3727|  1.65k|      if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (3727:11): [True: 62, False: 1.59k]
  ------------------
 3728|     62|        is_invalid_value = true;
 3729|     62|        return (std::numeric_limits<size_t>::max)();
 3730|     62|      }
 3731|  1.59k|      return val;
 3732|  1.65k|    } else {
 3733|     23|      is_invalid_value = true;
 3734|     23|    }
 3735|  1.68k|  }
 3736|  7.68k|  return def;
 3737|  9.34k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1365|  44.8k|  equal_range(const std::string &key) const {
 1366|  44.8k|    auto i = index_of(key);
 1367|  44.8k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1367:12): [True: 32.1k, False: 12.6k]
  ------------------
 1368|  44.8k|                       : std::make_pair(make_citer(i, i), end());
 1369|  44.8k|  }
_ZN7httplib6detail12bounded_nextINS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS3_4pairIS9_S9_EEEEEET_SI_mSI_:
 3705|  16.6k|template <typename It> inline It bounded_next(It first, size_t n, It last) {
 3706|  16.6k|  for (; n > 0 && first != last; --n) {
  ------------------
  |  Branch (3706:10): [True: 0, False: 16.6k]
  |  Branch (3706:19): [True: 0, False: 0]
  ------------------
 3707|      0|    ++first;
 3708|      0|  }
 3709|  16.6k|  return first;
 3710|  16.6k|}
_ZN7httplib6detail10is_numericERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 3700|  1.68k|inline bool is_numeric(const std::string &str) {
 3701|  1.68k|  return !str.empty() && std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
  ------------------
  |  Branch (3701:10): [True: 1.65k, False: 22]
  |  Branch (3701:26): [True: 1.65k, False: 1]
  ------------------
 3702|  1.68k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEptEv:
 1232|  28.4k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail10from_charsImEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  795|  1.65k|                                       T &value, int base = 10) {
  796|  1.65k|  value = 0;
  797|  1.65k|  const char *p = first;
  798|  1.65k|  bool negative = false;
  799|       |
  800|  1.65k|  if (p != last && *p == '-') {
  ------------------
  |  Branch (800:7): [True: 1.65k, False: 0]
  |  Branch (800:20): [True: 0, False: 1.65k]
  ------------------
  801|      0|    negative = true;
  802|      0|    ++p;
  803|      0|  }
  804|  1.65k|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (804:7): [True: 0, False: 1.65k]
  ------------------
  805|       |
  806|  1.65k|  auto radix = static_cast<T>(base);
  807|  1.65k|  T result = 0;
  808|  26.3k|  for (; p != last; ++p) {
  ------------------
  |  Branch (808:10): [True: 24.7k, False: 1.59k]
  ------------------
  809|  24.7k|    char c = *p;
  810|  24.7k|    int digit = -1;
  811|  24.7k|    if (is_ascii_digit(c)) {
  ------------------
  |  Branch (811:9): [True: 24.7k, False: 0]
  ------------------
  812|  24.7k|      digit = c - '0';
  813|  24.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|  24.7k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (821:9): [True: 0, False: 24.7k]
  |  Branch (821:22): [True: 0, False: 24.7k]
  ------------------
  822|  24.7k|    auto d = static_cast<T>(digit);
  823|  24.7k|    if (result > ((std::numeric_limits<T>::max)() - d) / radix) {
  ------------------
  |  Branch (823:9): [True: 62, False: 24.7k]
  ------------------
  824|     62|      return {p, std::errc::result_out_of_range};
  825|     62|    }
  826|  24.7k|    result = result * radix + d;
  827|  24.7k|  }
  828|       |
  829|  1.59k|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (829:7): [True: 0, False: 1.59k]
  |  Branch (829:22): [True: 0, False: 1.59k]
  |  Branch (829:34): [True: 0, False: 0]
  ------------------
  830|      0|    return {first, std::errc::invalid_argument};
  831|      0|  }
  832|       |
  833|  1.59k|  value = negative ? T(0) - result : result;
  ------------------
  |  Branch (833:11): [True: 0, False: 1.59k]
  ------------------
  834|  1.59k|  return {p, std::errc{}};
  835|  1.59k|}
_ZN7httplib6detail30has_conflicting_content_lengthERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9551|  4.03k|inline bool has_conflicting_content_length(const Headers &headers) {
 9552|       |  // RFC 9112 §6.3: a message carrying both Transfer-Encoding and a non-zero
 9553|       |  // Content-Length is framed ambiguously. The body readers here delimit it by
 9554|       |  // the transfer coding and drop Content-Length, while an intermediary may do
 9555|       |  // the reverse, so the two disagree on where the body ends and a reused
 9556|       |  // connection is desynchronised (request/response smuggling). Content-Length:
 9557|       |  // 0 is tolerated for compatibility with existing peers.
 9558|  4.03k|  return has_header(headers, "Transfer-Encoding") &&
  ------------------
  |  Branch (9558:10): [True: 0, False: 4.03k]
  ------------------
 9559|      0|         get_header_value_u64(headers, "Content-Length", 0, 0) > 0;
  ------------------
  |  Branch (9559:10): [True: 0, False: 0]
  ------------------
 9560|  4.03k|}
_ZN7httplib6detail10has_headerERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 9134|  27.7k|inline bool has_header(const Headers &headers, const std::string &key) {
 9135|  27.7k|  if (is_prohibited_header_name(key)) { return false; }
  ------------------
  |  Branch (9135:7): [True: 0, False: 27.7k]
  ------------------
 9136|  27.7k|  return headers.find(key) != headers.end();
 9137|  27.7k|}
_ZN7httplib6detail25is_prohibited_header_nameERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9126|  34.9k|inline bool is_prohibited_header_name(const std::string &name) {
 9127|       |  // Field names are case-insensitive (RFC 9110 §5.1)
 9128|  34.9k|  return case_ignore::equal(name, "REMOTE_ADDR") ||
  ------------------
  |  Branch (9128:10): [True: 0, False: 34.9k]
  ------------------
 9129|  34.9k|         case_ignore::equal(name, "REMOTE_PORT") ||
  ------------------
  |  Branch (9129:10): [True: 0, False: 34.9k]
  ------------------
 9130|  34.9k|         case_ignore::equal(name, "LOCAL_ADDR") ||
  ------------------
  |  Branch (9130:10): [True: 0, False: 34.9k]
  ------------------
 9131|  34.9k|         case_ignore::equal(name, "LOCAL_PORT");
  ------------------
  |  Branch (9131:10): [True: 0, False: 34.9k]
  ------------------
 9132|  34.9k|}
_ZN7httplib6detail11case_ignore5equalILm12EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  69.9k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  69.9k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 0, False: 69.9k]
  ------------------
  729|      0|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 0, False: 0]
  ------------------
  730|      0|           return to_lower(ca) == to_lower(cb);
  731|      0|         });
  732|  69.9k|}
_ZN7httplib6detail11case_ignore5equalILm11EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  69.9k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  69.9k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 0, False: 69.9k]
  ------------------
  729|      0|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 0, False: 0]
  ------------------
  730|      0|           return to_lower(ca) == to_lower(cb);
  731|      0|         });
  732|  69.9k|}
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mm:
 3741|  4.87k|                                   size_t id) {
 3742|  4.87k|  auto dummy = false;
 3743|  4.87k|  return get_header_value_u64(headers, key, def, id, dummy);
 3744|  4.87k|}
_ZNK7httplib7Request10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12875|  23.3k|inline bool Request::has_header(const std::string &key) const {
12876|  23.3k|  return detail::has_header(headers, key);
12877|  23.3k|}
_ZN7httplib6detail28is_chunked_transfer_encodingERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9512|  5.22k|inline bool is_chunked_transfer_encoding(const Headers &headers) {
 9513|       |  // RFC 9112 6.1: a message is framed with the chunked coding when "chunked"
 9514|       |  // is the final transfer coding. A single field value may list several
 9515|       |  // codings ("gzip, chunked"), and RFC 9110 5.3 lets that list be split across
 9516|       |  // several Transfer-Encoding lines, which combine into one comma-separated
 9517|       |  // list in the order the lines were received. Headers preserves that order,
 9518|       |  // so the final coding is the last token of the last line. Match it
 9519|       |  // case-insensitively rather than comparing the whole value against
 9520|       |  // "chunked".
 9521|       |  //
 9522|       |  // Security: reading a chunked message as unframed leaves its body in the
 9523|       |  // socket, where a keep-alive connection parses it as a smuggled request.
 9524|       |  // Server::process_request() answers 400 and closes when the final coding is
 9525|       |  // not chunked, so a request whose framing cannot be determined never
 9526|       |  // reaches the "no body" path.
 9527|  5.22k|  auto rng = headers.equal_range("Transfer-Encoding");
 9528|  5.22k|  if (rng.first == rng.second) { return false; }
  ------------------
  |  Branch (9528:7): [True: 5.22k, False: 0]
  ------------------
 9529|       |
 9530|       |  // Cleared per line, so a trailing line carrying no coding at all leaves the
 9531|       |  // combined list ending in nothing rather than inheriting the line before it.
 9532|      0|  std::string last_coding;
 9533|       |
 9534|      0|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9534:29): [True: 0, False: 0]
  ------------------
 9535|      0|    const auto &value = it->second;
 9536|      0|    last_coding.clear();
 9537|      0|    split(value.data(), value.data() + value.size(), ',',
 9538|      0|          [&](const char *b, const char *e) { last_coding.assign(b, e); });
 9539|      0|  }
 9540|       |
 9541|      0|  return case_ignore::equal(last_coding, "chunked");
 9542|  5.22k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEeqISF_EEbRKNSC_IT_EE:
 1270|  5.22k|    template <typename U> bool operator==(const iterator_t<U> &rhs) const {
 1271|  5.22k|      return idx_ == rhs.idx_;
 1272|  5.22k|    }
_ZNK7httplib7Request22get_header_value_countERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12884|  4.03k|inline size_t Request::get_header_value_count(const std::string &key) const {
12885|  4.03k|  return detail::get_header_value_count(headers, key);
12886|  4.03k|}
_ZN7httplib6detail22get_header_value_countERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 9158|  4.03k|                                     const std::string &key) {
 9159|  4.03k|  return headers.count(key);
 9160|  4.03k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5countERKS8_:
 1350|  4.03k|  size_type count(const std::string &key) const {
 1351|  4.03k|    size_type n = 0;
 1352|  12.7k|    for (const auto &entry : entries_) {
  ------------------
  |  Branch (1352:28): [True: 12.7k, False: 4.03k]
  ------------------
 1353|  12.7k|      if (keys_equal(entry.first, key)) { n++; }
  ------------------
  |  Branch (1353:11): [True: 735, False: 11.9k]
  ------------------
 1354|  12.7k|    }
 1355|  4.03k|    return n;
 1356|  4.03k|  }
_ZNK7httplib7Request16get_header_valueERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPKcm:
12880|  5.55k|                                             const char *def, size_t id) const {
12881|  5.55k|  return detail::get_header_value(headers, key, def, id);
12882|  5.55k|}
_ZN7httplib6detail16get_header_valueERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_PKcm:
 9141|  7.29k|                                    size_t id) {
 9142|  7.29k|  if (is_prohibited_header_name(key)) {
  ------------------
  |  Branch (9142:7): [True: 0, False: 7.29k]
  ------------------
 9143|      0|#ifndef CPPHTTPLIB_NO_EXCEPTIONS
 9144|      0|    std::string msg = "Prohibited header name '" + key + "' is specified.";
 9145|      0|    throw std::invalid_argument(msg);
 9146|       |#else
 9147|       |    return "";
 9148|       |#endif
 9149|      0|  }
 9150|       |
 9151|  7.29k|  auto rng = headers.equal_range(key);
 9152|  7.29k|  auto it = bounded_next(rng.first, id, rng.second);
 9153|  7.29k|  if (it != rng.second) { return it->second.c_str(); }
  ------------------
  |  Branch (9153:7): [True: 3.59k, False: 3.70k]
  ------------------
 9154|  3.70k|  return def;
 9155|  7.29k|}
_ZN7httplib6detail28has_faulty_transfer_encodingINS_7RequestEEEbRKT_:
 9546|  4.03k|template <typename T> inline bool has_faulty_transfer_encoding(const T &msg) {
 9547|  4.03k|  return msg.has_header("Transfer-Encoding") &&
  ------------------
  |  Branch (9547:10): [True: 0, False: 4.03k]
  ------------------
 9548|      0|         (msg.has_header("Content-Length") || msg.version == "HTTP/1.0");
  ------------------
  |  Branch (9548:11): [True: 0, False: 0]
  |  Branch (9548:47): [True: 0, False: 0]
  ------------------
 9549|  4.03k|}
_ZN7httplib6detail6fields7is_hostERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11317|  4.00k|inline bool is_host(const std::string &s) {
11318|  4.00k|  return std::all_of(s.begin(), s.end(), [](char c) {
11319|  4.00k|    return is_ascii_alnum(c) || c == '-' || c == '.' || c == '_' || c == '~' ||
11320|  4.00k|           c == '!' || c == '$' || c == '&' || c == '\'' || c == '(' ||
11321|  4.00k|           c == ')' || c == '*' || c == '+' || c == ',' || c == ';' ||
11322|  4.00k|           c == '=' || c == '%' || c == ':' || c == '[' || c == ']';
11323|  4.00k|  });
11324|  4.00k|}
_ZZN7httplib6detail6fields7is_hostERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEENKUlcE_clEc:
11318|  13.0k|  return std::all_of(s.begin(), s.end(), [](char c) {
11319|  13.0k|    return is_ascii_alnum(c) || c == '-' || c == '.' || c == '_' || c == '~' ||
  ------------------
  |  Branch (11319:12): [True: 7.80k, False: 5.24k]
  |  Branch (11319:33): [True: 196, False: 5.04k]
  |  Branch (11319:45): [True: 369, False: 4.67k]
  |  Branch (11319:57): [True: 207, False: 4.46k]
  |  Branch (11319:69): [True: 196, False: 4.27k]
  ------------------
11320|  4.27k|           c == '!' || c == '$' || c == '&' || c == '\'' || c == '(' ||
  ------------------
  |  Branch (11320:12): [True: 282, False: 3.99k]
  |  Branch (11320:24): [True: 224, False: 3.76k]
  |  Branch (11320:36): [True: 520, False: 3.24k]
  |  Branch (11320:48): [True: 265, False: 2.98k]
  |  Branch (11320:61): [True: 194, False: 2.78k]
  ------------------
11321|  2.78k|           c == ')' || c == '*' || c == '+' || c == ',' || c == ';' ||
  ------------------
  |  Branch (11321:12): [True: 209, False: 2.57k]
  |  Branch (11321:24): [True: 314, False: 2.26k]
  |  Branch (11321:36): [True: 255, False: 2.01k]
  |  Branch (11321:48): [True: 195, False: 1.81k]
  |  Branch (11321:60): [True: 196, False: 1.61k]
  ------------------
11322|  1.61k|           c == '=' || c == '%' || c == ':' || c == '[' || c == ']';
  ------------------
  |  Branch (11322:12): [True: 246, False: 1.37k]
  |  Branch (11322:24): [True: 207, False: 1.16k]
  |  Branch (11322:36): [True: 219, False: 947]
  |  Branch (11322:48): [True: 711, False: 236]
  |  Branch (11322:60): [True: 198, False: 38]
  ------------------
11323|  13.0k|  });
_ZN7httplib6detail16has_header_tokenERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SF_:
 9183|  20.1k|                             const std::string &token) {
 9184|       |  // RFC 9110 7.6.1: a comma-separated token list field such as Connection may
 9185|       |  // carry several tokens, and RFC 9110 5.3 lets that list be split across
 9186|       |  // several lines. Match complete tokens rather than searching the raw value,
 9187|       |  // so that a value such as "notupgrade" is not read as the token "upgrade".
 9188|  20.1k|  auto rng = headers.equal_range(key);
 9189|  22.9k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9189:29): [True: 8.28k, False: 14.6k]
  ------------------
 9190|  8.28k|    const auto &value = it->second;
 9191|  8.28k|    if (split_find(value.data(), value.data() + value.size(), ',',
  ------------------
  |  Branch (9191:9): [True: 5.49k, False: 2.79k]
  ------------------
 9192|  8.28k|                   [&](const char *b, const char *e) {
 9193|  8.28k|                     return case_ignore::equal(std::string(b, e), token);
 9194|  8.28k|                   })) {
 9195|  5.49k|      return true;
 9196|  5.49k|    }
 9197|  8.28k|  }
 9198|  14.6k|  return false;
 9199|  20.1k|}
_ZN7httplib6detail10split_findEPKcS2_cNSt3__18functionIFbS2_S2_EEE:
 6842|  8.41k|                       std::function<bool(const char *, const char *)> fn) {
 6843|  8.41k|  return split_find(b, e, d, (std::numeric_limits<size_t>::max)(),
 6844|  8.41k|                    std::move(fn));
 6845|  8.41k|}
_ZZN7httplib6detail16has_header_tokenERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SF_ENKUlPKcSH_E_clESH_SH_:
 9192|  14.3k|                   [&](const char *b, const char *e) {
 9193|  14.3k|                     return case_ignore::equal(std::string(b, e), token);
 9194|  14.3k|                   })) {
_ZN7httplib6detail16is_trusted_proxyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERKNS1_6vectorIS7_NS5_IS7_EEEE:
11401|  3.96k|                             const std::vector<std::string> &trusted_proxies) {
11402|  3.96k|  if (trusted_proxies.empty()) { return false; }
  ------------------
  |  Branch (11402:7): [True: 3.96k, False: 0]
  ------------------
11403|      0|  return std::find(trusted_proxies.begin(), trusted_proxies.end(),
11404|      0|                   canonical_ip(addr)) != trusted_proxies.end();
11405|  3.96k|}
_ZN7httplib6detail25get_combined_header_valueERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 9168|  2.78k|                                             const std::string &key) {
 9169|  2.78k|  std::string combined;
 9170|  2.78k|  auto rng = headers.equal_range(key);
 9171|  9.47k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9171:29): [True: 6.68k, False: 2.78k]
  ------------------
 9172|       |    // RFC 9110 Section 5.6.1.2: a recipient has to parse and ignore empty list
 9173|       |    // elements, so an empty field line must not contribute a bare comma to the
 9174|       |    // combined value.
 9175|  6.68k|    if (it->second.empty()) { continue; }
  ------------------
  |  Branch (9175:9): [True: 94, False: 6.59k]
  ------------------
 9176|  6.59k|    if (!combined.empty()) { combined += ", "; }
  ------------------
  |  Branch (9176:9): [True: 4.99k, False: 1.60k]
  ------------------
 9177|  6.59k|    combined += it->second;
 9178|  6.59k|  }
 9179|  2.78k|  return combined;
 9180|  2.78k|}
_ZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEE:
10321|  1.48k|                                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.48k|  if (s.find('"') != std::string::npos) {
  ------------------
  |  Branch (10324:7): [True: 121, False: 1.36k]
  ------------------
10325|    121|    return parse_accept_header(remove_quoted_strings(s), content_types);
10326|    121|  }
10327|       |
10328|  1.36k|  content_types.clear();
10329|       |
10330|       |  // Empty string is considered valid (no preference)
10331|  1.36k|  if (s.empty()) { return true; }
  ------------------
  |  Branch (10331:7): [True: 69, False: 1.29k]
  ------------------
10332|       |
10333|  1.29k|  struct AcceptEntry {
10334|  1.29k|    std::string media_type;
10335|  1.29k|    double quality;
10336|  1.29k|    int order;
10337|  1.29k|  };
10338|       |
10339|  1.29k|  std::vector<AcceptEntry> entries;
10340|  1.29k|  int order = 0;
10341|  1.29k|  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.29k|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
10350|  1.29k|    std::string entry(b, e);
10351|  1.29k|    entry = trim_copy(entry);
10352|       |
10353|  1.29k|    AcceptEntry accept_entry;
10354|  1.29k|    accept_entry.order = order++;
10355|       |
10356|  1.29k|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
10357|  1.29k|                       accept_entry.media_type, accept_entry.quality)) {
10358|  1.29k|      has_invalid_entry = true;
10359|  1.29k|      return;
10360|  1.29k|    }
10361|       |
10362|       |    // Remove additional parameters from media type
10363|  1.29k|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
10364|       |
10365|       |    // Basic validation of media type format
10366|  1.29k|    if (accept_entry.media_type.empty()) {
10367|  1.29k|      has_invalid_entry = true;
10368|  1.29k|      return;
10369|  1.29k|    }
10370|       |
10371|       |    // Check for basic media type format (should contain '/' or be '*')
10372|  1.29k|    if (accept_entry.media_type != "*" &&
10373|  1.29k|        accept_entry.media_type.find('/') == std::string::npos) {
10374|  1.29k|      has_invalid_entry = true;
10375|  1.29k|      return;
10376|  1.29k|    }
10377|       |
10378|  1.29k|    entries.push_back(std::move(accept_entry));
10379|  1.29k|  });
10380|       |
10381|       |  // Return false if any invalid entry was found
10382|  1.29k|  if (has_invalid_entry) { return false; }
  ------------------
  |  Branch (10382:7): [True: 524, False: 773]
  ------------------
10383|       |
10384|       |  // Sort by quality (descending), then by original order (ascending)
10385|    773|  std::sort(entries.begin(), entries.end(),
10386|    773|            [](const AcceptEntry &a, const AcceptEntry &b) {
10387|    773|              if (a.quality != b.quality) {
10388|    773|                return a.quality > b.quality; // Higher quality first
10389|    773|              }
10390|    773|              return a.order < b.order; // Earlier order first for same quality
10391|    773|            });
10392|       |
10393|       |  // Extract sorted media types
10394|    773|  content_types.reserve(entries.size());
10395|  3.72M|  for (auto &entry : entries) {
  ------------------
  |  Branch (10395:20): [True: 3.72M, False: 773]
  ------------------
10396|  3.72M|    content_types.push_back(std::move(entry.media_type));
10397|  3.72M|  }
10398|       |
10399|    773|  return true;
10400|  1.29k|}
_ZN7httplib6detail21remove_quoted_stringsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
10305|    121|inline std::string remove_quoted_strings(const std::string &s) {
10306|    121|  std::string out;
10307|    121|  auto in_quotes = false;
10308|  4.23M|  for (size_t i = 0; i < s.size(); i++) {
  ------------------
  |  Branch (10308:22): [True: 4.23M, False: 121]
  ------------------
10309|  4.23M|    if (s[i] == '"') {
  ------------------
  |  Branch (10309:9): [True: 911, False: 4.23M]
  ------------------
10310|    911|      in_quotes = !in_quotes;
10311|  4.23M|    } else if (!in_quotes) {
  ------------------
  |  Branch (10311:16): [True: 4.16M, False: 74.7k]
  ------------------
10312|  4.16M|      out += s[i];
10313|  4.16M|    } else if (s[i] == '\\') {
  ------------------
  |  Branch (10313:16): [True: 198, False: 74.5k]
  ------------------
10314|    198|      i++;
10315|    198|    }
10316|  4.23M|  }
10317|    121|  return out;
10318|    121|}
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlPKcSF_E_clESF_SF_:
10349|  4.51M|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
10350|  4.51M|    std::string entry(b, e);
10351|  4.51M|    entry = trim_copy(entry);
10352|       |
10353|  4.51M|    AcceptEntry accept_entry;
10354|  4.51M|    accept_entry.order = order++;
10355|       |
10356|  4.51M|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
  ------------------
  |  Branch (10356:9): [True: 2.13k, False: 4.50M]
  ------------------
10357|  4.51M|                       accept_entry.media_type, accept_entry.quality)) {
10358|  2.13k|      has_invalid_entry = true;
10359|  2.13k|      return;
10360|  2.13k|    }
10361|       |
10362|       |    // Remove additional parameters from media type
10363|  4.50M|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
10364|       |
10365|       |    // Basic validation of media type format
10366|  4.50M|    if (accept_entry.media_type.empty()) {
  ------------------
  |  Branch (10366:9): [True: 0, False: 4.50M]
  ------------------
10367|      0|      has_invalid_entry = true;
10368|      0|      return;
10369|      0|    }
10370|       |
10371|       |    // Check for basic media type format (should contain '/' or be '*')
10372|  4.50M|    if (accept_entry.media_type != "*" &&
  ------------------
  |  Branch (10372:9): [True: 2.87M, False: 1.63M]
  ------------------
10373|  2.87M|        accept_entry.media_type.find('/') == std::string::npos) {
  ------------------
  |  Branch (10373:9): [True: 1.92k, False: 2.87M]
  ------------------
10374|  1.92k|      has_invalid_entry = true;
10375|  1.92k|      return;
10376|  1.92k|    }
10377|       |
10378|  4.50M|    entries.push_back(std::move(accept_entry));
10379|  4.50M|  });
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlRKZNS0_19parse_accept_headerES9_SD_E11AcceptEntrySG_E_clESG_SG_:
10386|  82.6M|            [](const AcceptEntry &a, const AcceptEntry &b) {
10387|  82.6M|              if (a.quality != b.quality) {
  ------------------
  |  Branch (10387:19): [True: 160k, False: 82.5M]
  ------------------
10388|   160k|                return a.quality > b.quality; // Higher quality first
10389|   160k|              }
10390|  82.5M|              return a.order < b.order; // Earlier order first for same quality
10391|  82.6M|            });
_ZN7httplib6detail11case_ignore5equalILm6EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  1.23k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  1.23k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 1.20k, False: 32]
  ------------------
  729|  1.20k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 1.19k, False: 13]
  ------------------
  730|  1.20k|           return to_lower(ca) == to_lower(cb);
  731|  1.20k|         });
  732|  1.23k|}
_ZZN7httplib6detail11case_ignore5equalILm6EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  5.99k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  5.99k|           return to_lower(ca) == to_lower(cb);
  731|  5.99k|         });
_ZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEE:
10240|  1.19k|inline bool parse_range_header(const std::string &s, Ranges &ranges) try {
10241|  1.19k|#endif
10242|  1.19k|  auto is_valid = [](const std::string &str) {
10243|  1.19k|    return std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
10244|  1.19k|  };
10245|       |
10246|  1.19k|  if (s.size() > 7 && case_ignore::equal(s.substr(0, 6), "bytes=")) {
  ------------------
  |  Branch (10246:7): [True: 1.18k, False: 7]
  |  Branch (10246:7): [True: 1.18k, False: 7]
  |  Branch (10246:23): [True: 1.18k, False: 0]
  ------------------
10247|  1.18k|    const auto pos = static_cast<size_t>(6);
10248|  1.18k|    const auto len = static_cast<size_t>(s.size() - 6);
10249|  1.18k|    auto all_valid_ranges = true;
10250|  1.18k|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
10251|  1.18k|      if (!all_valid_ranges) { return; }
10252|       |
10253|  1.18k|      const auto it = std::find(b, e, '-');
10254|  1.18k|      if (it == e) {
10255|  1.18k|        all_valid_ranges = false;
10256|  1.18k|        return;
10257|  1.18k|      }
10258|       |
10259|  1.18k|      const auto lhs = std::string(b, it);
10260|  1.18k|      const auto rhs = std::string(it + 1, e);
10261|  1.18k|      if (!is_valid(lhs) || !is_valid(rhs)) {
10262|  1.18k|        all_valid_ranges = false;
10263|  1.18k|        return;
10264|  1.18k|      }
10265|       |
10266|  1.18k|      ssize_t first = -1;
10267|  1.18k|      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|  1.18k|        auto res =
10271|  1.18k|            detail::from_chars(lhs.data(), lhs.data() + lhs.size(), first);
10272|  1.18k|        if (res.ec != std::errc{}) {
10273|  1.18k|          all_valid_ranges = false;
10274|  1.18k|          return;
10275|  1.18k|        }
10276|  1.18k|      }
10277|       |
10278|  1.18k|      ssize_t last = -1;
10279|  1.18k|      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|  1.18k|        ssize_t v;
10283|  1.18k|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
10284|  1.18k|        if (res.ec == std::errc{}) { last = v; }
10285|  1.18k|      }
10286|       |
10287|  1.18k|      if ((first == -1 && last == -1) ||
10288|  1.18k|          (first != -1 && last != -1 && first > last)) {
10289|  1.18k|        all_valid_ranges = false;
10290|  1.18k|        return;
10291|  1.18k|      }
10292|       |
10293|  1.18k|      ranges.emplace_back(first, last);
10294|  1.18k|    });
10295|  1.18k|    return all_valid_ranges && !ranges.empty();
  ------------------
  |  Branch (10295:12): [True: 995, False: 190]
  |  Branch (10295:32): [True: 995, False: 0]
  ------------------
10296|  1.18k|  }
10297|      7|  return false;
10298|       |#ifdef CPPHTTPLIB_NO_EXCEPTIONS
10299|       |}
10300|       |#else
10301|  1.19k|} catch (...) { return false; }
_ZN7httplib6detail11case_ignore5equalILm7EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  1.18k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  1.18k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 1.18k, False: 0]
  ------------------
  729|  1.18k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 1.18k, False: 0]
  ------------------
  730|  1.18k|           return to_lower(ca) == to_lower(cb);
  731|  1.18k|         });
  732|  1.18k|}
_ZZN7httplib6detail11case_ignore5equalILm7EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  7.11k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  7.11k|           return to_lower(ca) == to_lower(cb);
  731|  7.11k|         });
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlPKcSH_E_clESH_SH_:
10250|  33.0k|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
10251|  33.0k|      if (!all_valid_ranges) { return; }
  ------------------
  |  Branch (10251:11): [True: 15.5k, False: 17.5k]
  ------------------
10252|       |
10253|  17.5k|      const auto it = std::find(b, e, '-');
10254|  17.5k|      if (it == e) {
  ------------------
  |  Branch (10254:11): [True: 27, False: 17.4k]
  ------------------
10255|     27|        all_valid_ranges = false;
10256|     27|        return;
10257|     27|      }
10258|       |
10259|  17.4k|      const auto lhs = std::string(b, it);
10260|  17.4k|      const auto rhs = std::string(it + 1, e);
10261|  17.4k|      if (!is_valid(lhs) || !is_valid(rhs)) {
  ------------------
  |  Branch (10261:11): [True: 8, False: 17.4k]
  |  Branch (10261:29): [True: 3, False: 17.4k]
  ------------------
10262|     11|        all_valid_ranges = false;
10263|     11|        return;
10264|     11|      }
10265|       |
10266|  17.4k|      ssize_t first = -1;
10267|  17.4k|      if (!lhs.empty()) {
  ------------------
  |  Branch (10267:11): [True: 2.23k, False: 15.2k]
  ------------------
10268|       |        // Reject an overflowing first-byte-pos; treating it as absent (-1)
10269|       |        // would turn the range into a suffix range.
10270|  2.23k|        auto res =
10271|  2.23k|            detail::from_chars(lhs.data(), lhs.data() + lhs.size(), first);
10272|  2.23k|        if (res.ec != std::errc{}) {
  ------------------
  |  Branch (10272:13): [True: 25, False: 2.20k]
  ------------------
10273|     25|          all_valid_ranges = false;
10274|     25|          return;
10275|     25|        }
10276|  2.23k|      }
10277|       |
10278|  17.4k|      ssize_t last = -1;
10279|  17.4k|      if (!rhs.empty()) {
  ------------------
  |  Branch (10279:11): [True: 16.3k, False: 1.06k]
  ------------------
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|  16.3k|        ssize_t v;
10283|  16.3k|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
10284|  16.3k|        if (res.ec == std::errc{}) { last = v; }
  ------------------
  |  Branch (10284:13): [True: 16.1k, False: 232]
  ------------------
10285|  16.3k|      }
10286|       |
10287|  17.4k|      if ((first == -1 && last == -1) ||
  ------------------
  |  Branch (10287:12): [True: 15.2k, False: 2.20k]
  |  Branch (10287:27): [True: 50, False: 15.1k]
  ------------------
10288|  17.3k|          (first != -1 && last != -1 && first > last)) {
  ------------------
  |  Branch (10288:12): [True: 2.20k, False: 15.1k]
  |  Branch (10288:27): [True: 957, False: 1.25k]
  |  Branch (10288:41): [True: 77, False: 880]
  ------------------
10289|    127|        all_valid_ranges = false;
10290|    127|        return;
10291|    127|      }
10292|       |
10293|  17.3k|      ranges.emplace_back(first, last);
10294|  17.3k|    });
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlS9_E_clES9_:
10242|  34.9k|  auto is_valid = [](const std::string &str) {
10243|  34.9k|    return std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
10244|  34.9k|  };
_ZN7httplib6detail10from_charsIlEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  795|  18.6k|                                       T &value, int base = 10) {
  796|  18.6k|  value = 0;
  797|  18.6k|  const char *p = first;
  798|  18.6k|  bool negative = false;
  799|       |
  800|  18.6k|  if (p != last && *p == '-') {
  ------------------
  |  Branch (800:7): [True: 18.6k, False: 0]
  |  Branch (800:20): [True: 0, False: 18.6k]
  ------------------
  801|      0|    negative = true;
  802|      0|    ++p;
  803|      0|  }
  804|  18.6k|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (804:7): [True: 0, False: 18.6k]
  ------------------
  805|       |
  806|  18.6k|  auto radix = static_cast<T>(base);
  807|  18.6k|  T result = 0;
  808|  49.5k|  for (; p != last; ++p) {
  ------------------
  |  Branch (808:10): [True: 31.2k, False: 18.3k]
  ------------------
  809|  31.2k|    char c = *p;
  810|  31.2k|    int digit = -1;
  811|  31.2k|    if (is_ascii_digit(c)) {
  ------------------
  |  Branch (811:9): [True: 31.2k, False: 0]
  ------------------
  812|  31.2k|      digit = c - '0';
  813|  31.2k|    } 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|  31.2k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (821:9): [True: 0, False: 31.2k]
  |  Branch (821:22): [True: 0, False: 31.2k]
  ------------------
  822|  31.2k|    auto d = static_cast<T>(digit);
  823|  31.2k|    if (result > ((std::numeric_limits<T>::max)() - d) / radix) {
  ------------------
  |  Branch (823:9): [True: 257, False: 30.9k]
  ------------------
  824|    257|      return {p, std::errc::result_out_of_range};
  825|    257|    }
  826|  30.9k|    result = result * radix + d;
  827|  30.9k|  }
  828|       |
  829|  18.3k|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (829:7): [True: 0, False: 18.3k]
  |  Branch (829:22): [True: 0, False: 18.3k]
  |  Branch (829:34): [True: 0, False: 0]
  ------------------
  830|      0|    return {first, std::errc::invalid_argument};
  831|      0|  }
  832|       |
  833|  18.3k|  value = negative ? T(0) - result : result;
  ------------------
  |  Branch (833:11): [True: 0, False: 18.3k]
  ------------------
  834|  18.3k|  return {p, std::errc{}};
  835|  18.3k|}
_ZN7httplib6detail20is_websocket_upgradeERKNS_7RequestE:
 6127|  3.24k|inline bool is_websocket_upgrade(const Request &req) {
 6128|  3.24k|  if (req.method != "GET") { return false; }
  ------------------
  |  Branch (6128:7): [True: 223, False: 3.01k]
  ------------------
 6129|       |
 6130|       |  // Check Upgrade: websocket. RFC 9110 7.8 defines Upgrade as a comma-separated
 6131|       |  // list of protocols and asks recipients to match each name
 6132|       |  // case-insensitively, so look for the token rather than compare the whole
 6133|       |  // field value.
 6134|  3.01k|  if (!has_header_token(req.headers, "Upgrade", "websocket")) { return false; }
  ------------------
  |  Branch (6134:7): [True: 3.01k, False: 0]
  ------------------
 6135|       |
 6136|       |  // Check Connection: Upgrade
 6137|      0|  if (!has_header_token(req.headers, "Connection", "upgrade")) { return false; }
  ------------------
  |  Branch (6137:7): [True: 0, False: 0]
  ------------------
 6138|       |
 6139|       |  // Check Sec-WebSocket-Key is a valid base64-encoded 16-byte value (24 chars)
 6140|       |  // RFC 6455 Section 4.2.1
 6141|      0|  auto ws_key = req.get_header_value("Sec-WebSocket-Key");
 6142|      0|  if (ws_key.size() != 24 || ws_key[22] != '=' || ws_key[23] != '=') {
  ------------------
  |  Branch (6142:7): [True: 0, False: 0]
  |  Branch (6142:30): [True: 0, False: 0]
  |  Branch (6142:51): [True: 0, False: 0]
  ------------------
 6143|      0|    return false;
 6144|      0|  }
 6145|      0|  static const std::string b64chars =
 6146|      0|      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 6147|      0|  for (size_t i = 0; i < 22; i++) {
  ------------------
  |  Branch (6147:22): [True: 0, False: 0]
  ------------------
 6148|      0|    if (b64chars.find(ws_key[i]) == std::string::npos) { return false; }
  ------------------
  |  Branch (6148:9): [True: 0, False: 0]
  ------------------
 6149|      0|  }
 6150|       |
 6151|       |  // Check Sec-WebSocket-Version: 13
 6152|      0|  auto version = req.get_header_value("Sec-WebSocket-Version");
 6153|      0|  if (version != "13") { return false; }
  ------------------
  |  Branch (6153:7): [True: 0, False: 0]
  ------------------
 6154|       |
 6155|      0|  return true;
 6156|      0|}
_ZN7httplib6detail15has_framed_bodyERKNS_7RequestE:
11182|  4.87k|inline bool has_framed_body(const Request &req) {
11183|  4.87k|  return is_chunked_transfer_encoding(req.headers) ||
  ------------------
  |  Branch (11183:10): [True: 0, False: 4.87k]
  ------------------
11184|  4.87k|         req.get_header_value_u64("Content-Length") > 0;
  ------------------
  |  Branch (11184:10): [True: 694, False: 4.17k]
  ------------------
11185|  4.87k|}
_ZNK7httplib7Request20get_header_value_u64ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEmm:
12871|  4.87k|                                            size_t id) const {
12872|  4.87k|  return detail::get_header_value_u64(headers, key, def, id);
12873|  4.87k|}
_ZN7httplib6Server27write_response_with_contentERNS_6StreamEbRKNS_7RequestERNS_8ResponseE:
15182|  1.43k|                                                Response &res) {
15183|  1.43k|  return write_response_core(strm, close_connection, req, res, true);
15184|  1.43k|}
_ZN7httplib6detail6fields14is_field_valueERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11303|  37.5k|inline bool is_field_value(const std::string &s) { return is_field_content(s); }
_ZN7httplib6detail6fields16is_field_contentERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11278|  37.5k|inline bool is_field_content(const std::string &s) {
11279|  37.5k|  if (s.empty()) { return true; }
  ------------------
  |  Branch (11279:7): [True: 4.15k, False: 33.3k]
  ------------------
11280|       |
11281|  33.3k|  if (s.size() == 1) {
  ------------------
  |  Branch (11281:7): [True: 5.04k, False: 28.3k]
  ------------------
11282|  5.04k|    return is_field_vchar(s[0]);
11283|  28.3k|  } else if (s.size() == 2) {
  ------------------
  |  Branch (11283:14): [True: 1.64k, False: 26.7k]
  ------------------
11284|  1.64k|    return is_field_vchar(s[0]) && is_field_vchar(s[1]);
  ------------------
  |  Branch (11284:12): [True: 1.64k, False: 1]
  |  Branch (11284:36): [True: 1.64k, False: 0]
  ------------------
11285|  26.7k|  } else {
11286|  26.7k|    size_t i = 0;
11287|       |
11288|  26.7k|    if (!is_field_vchar(s[i])) { return false; }
  ------------------
  |  Branch (11288:9): [True: 1, False: 26.7k]
  ------------------
11289|  26.7k|    i++;
11290|       |
11291|  21.9M|    while (i < s.size() - 1) {
  ------------------
  |  Branch (11291:12): [True: 21.9M, False: 26.6k]
  ------------------
11292|  21.9M|      auto c = s[i++];
11293|  21.9M|      if (c == ' ' || c == '\t' || is_field_vchar(c)) {
  ------------------
  |  Branch (11293:11): [True: 126k, False: 21.8M]
  |  Branch (11293:23): [True: 3.89k, False: 21.8M]
  |  Branch (11293:36): [True: 21.8M, False: 27]
  ------------------
11294|  21.9M|      } else {
11295|     27|        return false;
11296|     27|      }
11297|  21.9M|    }
11298|       |
11299|  26.6k|    return is_field_vchar(s[i]);
11300|  26.7k|  }
11301|  33.3k|}
_ZNK7httplib6Stream9get_errorEv:
 2092|    339|  Error get_error() const { return error_; }
_ZN7httplib6detail14fits_in_size_tEm:
 5825|  1.54k|inline bool fits_in_size_t(uint64_t n) {
 5826|  1.54k|  return static_cast<uint64_t>(static_cast<size_t>(n)) == n;
 5827|  1.54k|}
_ZN7httplib6Server7routingERNS_7RequestERNS_8ResponseERNS_6StreamEb:
15817|  3.24k|                            bool skip_pre_routing) {
15818|  3.24k|  if (!skip_pre_routing && pre_routing_handler_ &&
  ------------------
  |  Branch (15818:7): [True: 3.24k, False: 0]
  |  Branch (15818:28): [True: 0, False: 3.24k]
  ------------------
15819|      0|      pre_routing_handler_(req, res) == HandlerResponse::Handled) {
  ------------------
  |  Branch (15819:7): [True: 0, False: 0]
  ------------------
15820|      0|    return true;
15821|      0|  }
15822|       |
15823|       |  // File handler
15824|  3.24k|  if ((req.method == "GET" || req.method == "HEAD") &&
  ------------------
  |  Branch (15824:8): [True: 3.01k, False: 223]
  |  Branch (15824:31): [True: 210, False: 13]
  ------------------
15825|  3.22k|      handle_file_request(req, res)) {
  ------------------
  |  Branch (15825:7): [True: 1.60k, False: 1.62k]
  ------------------
15826|  1.60k|    return true;
15827|  1.60k|  }
15828|       |
15829|  1.63k|  const auto *custom = find_custom_entry(req.method);
15830|       |
15831|       |  // The second clause mirrors what expect_content() does unconditionally for
15832|       |  // POST/PUT/PATCH/DELETE: a content reader route fires even when the request
15833|       |  // carries no body. Without it a body-less PROPFIND (RFC 4918 treats one as
15834|       |  // `allprop`) would skip its handler and fall through to 404.
15835|  1.63k|  if (detail::expect_content(req) ||
  ------------------
  |  Branch (15835:7): [True: 175, False: 1.46k]
  ------------------
15836|  1.46k|      (custom && !custom->handlers_for_content_reader.empty())) {
  ------------------
  |  Branch (15836:8): [True: 0, False: 1.46k]
  |  Branch (15836:18): [True: 0, False: 0]
  ------------------
15837|       |    // Content reader handler
15838|    175|    {
15839|       |      // Track whether the ContentReader was aborted due to the decompressed
15840|       |      // payload exceeding `payload_max_length_`.
15841|       |      // The user handler runs after the lambda returns, so we must restore the
15842|       |      // 413 status if the handler overwrites it.
15843|    175|      bool content_reader_payload_too_large = false;
15844|       |
15845|    175|      ContentReader reader(
15846|    175|          [&](ContentReceiver receiver) {
15847|    175|            auto result = read_content_with_content_receiver(
15848|    175|                strm, req, res, std::move(receiver), nullptr, nullptr);
15849|    175|            if (!result) {
15850|    175|              output_error_log(Error::Read, &req);
15851|    175|              if (res.status == StatusCode::PayloadTooLarge_413) {
15852|    175|                content_reader_payload_too_large = true;
15853|    175|              }
15854|    175|            }
15855|    175|            return result;
15856|    175|          },
15857|    175|          [&](FormDataHeader header, ContentReceiver receiver) {
15858|    175|            auto result = read_content_with_content_receiver(
15859|    175|                strm, req, res, nullptr, std::move(header),
15860|    175|                std::move(receiver));
15861|    175|            if (!result) {
15862|    175|              output_error_log(Error::Read, &req);
15863|    175|              if (res.status == StatusCode::PayloadTooLarge_413) {
15864|    175|                content_reader_payload_too_large = true;
15865|    175|              }
15866|    175|            }
15867|    175|            return result;
15868|    175|          });
15869|       |
15870|    175|      bool dispatched = false;
15871|    175|      if (req.method == "POST") {
  ------------------
  |  Branch (15871:11): [True: 1, False: 174]
  ------------------
15872|      1|        dispatched = dispatch_request_for_content_reader(
15873|      1|            req, res, std::move(reader), post_handlers_for_content_reader_);
15874|    174|      } else if (req.method == "PUT") {
  ------------------
  |  Branch (15874:18): [True: 8, False: 166]
  ------------------
15875|      8|        dispatched = dispatch_request_for_content_reader(
15876|      8|            req, res, std::move(reader), put_handlers_for_content_reader_);
15877|    166|      } else if (req.method == "PATCH") {
  ------------------
  |  Branch (15877:18): [True: 1, False: 165]
  ------------------
15878|      1|        dispatched = dispatch_request_for_content_reader(
15879|      1|            req, res, std::move(reader), patch_handlers_for_content_reader_);
15880|    165|      } else if (req.method == "DELETE") {
  ------------------
  |  Branch (15880:18): [True: 1, False: 164]
  ------------------
15881|      1|        dispatched = dispatch_request_for_content_reader(
15882|      1|            req, res, std::move(reader), delete_handlers_for_content_reader_);
15883|    164|      } else if (custom) {
  ------------------
  |  Branch (15883:18): [True: 0, False: 164]
  ------------------
15884|      0|        dispatched = dispatch_request_for_content_reader(
15885|      0|            req, res, std::move(reader), custom->handlers_for_content_reader);
15886|      0|      }
15887|       |
15888|    175|      if (dispatched) {
  ------------------
  |  Branch (15888:11): [True: 0, False: 175]
  ------------------
15889|      0|        if (content_reader_payload_too_large) {
  ------------------
  |  Branch (15889:13): [True: 0, False: 0]
  ------------------
15890|       |          // Enforce the limit: override any status the handler may have set
15891|       |          // and return false so the error path sends a plain 413 response.
15892|      0|          res.status = StatusCode::PayloadTooLarge_413;
15893|      0|          detail::clear_content(res);
15894|      0|          return false;
15895|      0|        }
15896|      0|        return true;
15897|      0|      }
15898|    175|    }
15899|       |
15900|       |    // NOTE: `req.body` is not read here. For a regular handler the body is
15901|       |    // read inside dispatch_request(), after the route has matched and the
15902|       |    // pre-request handler has approved the request, so that a rejected
15903|       |    // request (e.g. failed authentication) never forces us to buffer a
15904|       |    // potentially large body.
15905|    175|  }
15906|       |
15907|       |  // Regular handler
15908|  1.63k|  if (req.method == "GET" || req.method == "HEAD") {
  ------------------
  |  Branch (15908:7): [True: 1.59k, False: 44]
  |  Branch (15908:30): [True: 31, False: 13]
  ------------------
15909|  1.62k|    return dispatch_request(req, res, get_handlers_, strm);
15910|  1.62k|  } else if (req.method == "POST") {
  ------------------
  |  Branch (15910:14): [True: 1, False: 12]
  ------------------
15911|      1|    return dispatch_request(req, res, post_handlers_, strm);
15912|     12|  } else if (req.method == "PUT") {
  ------------------
  |  Branch (15912:14): [True: 8, False: 4]
  ------------------
15913|      8|    return dispatch_request(req, res, put_handlers_, strm);
15914|      8|  } else if (req.method == "DELETE") {
  ------------------
  |  Branch (15914:14): [True: 1, False: 3]
  ------------------
15915|      1|    return dispatch_request(req, res, delete_handlers_, strm);
15916|      3|  } else if (req.method == "OPTIONS") {
  ------------------
  |  Branch (15916:14): [True: 1, False: 2]
  ------------------
15917|      1|    return dispatch_request(req, res, options_handlers_, strm);
15918|      2|  } else if (req.method == "PATCH") {
  ------------------
  |  Branch (15918:14): [True: 1, False: 1]
  ------------------
15919|      1|    return dispatch_request(req, res, patch_handlers_, strm);
15920|      1|  } else if (custom) {
  ------------------
  |  Branch (15920:14): [True: 0, False: 1]
  ------------------
15921|      0|    return dispatch_request(req, res, custom->handlers, strm);
15922|      0|  }
15923|       |
15924|      1|  res.status = StatusCode::BadRequest_400;
15925|      1|  return false;
15926|  1.63k|}
_ZN7httplib6Server19handle_file_requestERNS_7RequestERNS_8ResponseE:
15491|  3.22k|inline bool Server::handle_file_request(Request &req, Response &res) {
15492|  3.22k|  if (!detail::is_valid_path(req.path)) { return false; }
  ------------------
  |  Branch (15492:7): [True: 1.24k, False: 1.98k]
  ------------------
15493|       |
15494|  1.98k|  for (const auto &entry : base_dirs_) {
  ------------------
  |  Branch (15494:26): [True: 1.98k, False: 377]
  ------------------
15495|       |    // Prefix match, on a path segment boundary. A mount point of "/mount"
15496|       |    // covers "/mount" and "/mount/...", but must not swallow "/mountdir/...".
15497|       |    // One that already ends in '/' (the root mount among them) carries its own
15498|       |    // boundary; set_mount_point() guarantees the mount point is not empty.
15499|  1.98k|    if (!req.path.compare(0, entry.mount_point.size(), entry.mount_point) &&
  ------------------
  |  Branch (15499:9): [True: 1.70k, False: 277]
  ------------------
15500|  1.70k|        (entry.mount_point.back() == '/' ||
  ------------------
  |  Branch (15500:10): [True: 0, False: 1.70k]
  ------------------
15501|  1.70k|         req.path.size() == entry.mount_point.size() ||
  ------------------
  |  Branch (15501:10): [True: 1.52k, False: 181]
  ------------------
15502|  1.67k|         req.path[entry.mount_point.size()] == '/')) {
  ------------------
  |  Branch (15502:10): [True: 157, False: 24]
  ------------------
15503|  1.67k|      std::string sub_path = "/" + req.path.substr(entry.mount_point.size());
15504|  1.67k|      auto path = entry.base_dir + sub_path;
15505|  1.67k|      if (path.back() == '/') { path += "index.html"; }
  ------------------
  |  Branch (15505:11): [True: 1.54k, False: 134]
  ------------------
15506|       |
15507|       |      // Defense-in-depth: is_valid_path blocks ".." traversal in the URL,
15508|       |      // but symlinks/junctions can still escape the base directory. A path
15509|       |      // that cannot be resolved, which includes one that does not exist, is
15510|       |      // not served from here.
15511|  1.67k|      std::string resolved_path;
15512|  1.67k|      if (!detail::canonicalize_path(path.c_str(), resolved_path)) { continue; }
  ------------------
  |  Branch (15512:11): [True: 76, False: 1.60k]
  ------------------
15513|  1.60k|      if (!detail::is_path_within_base(resolved_path,
  ------------------
  |  Branch (15513:11): [True: 4, False: 1.59k]
  ------------------
15514|  1.60k|                                       entry.resolved_base_dir)) {
15515|      4|        res.status = StatusCode::Forbidden_403;
15516|      4|        return true;
15517|      4|      }
15518|       |
15519|  1.59k|      detail::FileStat stat(path);
15520|       |
15521|  1.59k|      if (stat.is_dir()) {
  ------------------
  |  Branch (15521:11): [True: 6, False: 1.59k]
  ------------------
15522|       |        // Relative, so "//dir" cannot name another host; "./" keeps a ':'
15523|       |        // in the name from reading as a scheme.
15524|      6|        auto name = req.path.substr(req.path.rfind('/') + 1);
15525|      6|        res.set_redirect("./" + encode_path_component(name) + "/",
15526|      6|                         StatusCode::MovedPermanently_301);
15527|      6|        return true;
15528|      6|      }
15529|       |
15530|  1.59k|      if (stat.is_file()) {
  ------------------
  |  Branch (15530:11): [True: 1.59k, False: 0]
  ------------------
15531|  1.59k|        for (const auto &kv : entry.headers) {
  ------------------
  |  Branch (15531:29): [True: 0, False: 1.59k]
  ------------------
15532|      0|          res.set_header(kv.first, kv.second);
15533|      0|        }
15534|       |
15535|  1.59k|        auto content_type = detail::find_content_type(
15536|  1.59k|            path, file_extension_and_mimetype_map_, default_file_mimetype_);
15537|  1.59k|        auto encoding = detail::EncodingType::None;
15538|  1.59k|        if (static_file_compression_) {
  ------------------
  |  Branch (15538:13): [True: 0, False: 1.59k]
  ------------------
15539|      0|          encoding = static_file_encoding(req, res, content_type, stat.size());
15540|      0|        }
15541|       |
15542|       |        // The ETag names the representation actually sent, so a client that
15543|       |        // cached the compressed form revalidates against the compressed ETag
15544|       |        // and still gets a 304, while one that took identity keeps the plain
15545|       |        // ETag.
15546|  1.59k|        auto etag = detail::compute_etag(
15547|  1.59k|            stat, encoding == detail::EncodingType::None
  ------------------
  |  Branch (15547:19): [True: 1.59k, False: 0]
  ------------------
15548|  1.59k|                      ? std::string()
15549|  1.59k|                      : std::string("-") + detail::encoding_name(encoding));
15550|  1.59k|        if (!etag.empty()) { res.set_header("ETag", etag); }
  ------------------
  |  Branch (15550:13): [True: 1.59k, False: 0]
  ------------------
15551|       |
15552|  1.59k|        auto mtime = stat.mtime();
15553|       |
15554|  1.59k|        auto last_modified = detail::file_mtime_to_http_date(mtime);
15555|  1.59k|        if (!last_modified.empty()) {
  ------------------
  |  Branch (15555:13): [True: 1.59k, False: 0]
  ------------------
15556|  1.59k|          res.set_header("Last-Modified", last_modified);
15557|  1.59k|        }
15558|       |
15559|  1.59k|        if (check_if_not_modified(req, res, etag, mtime)) { return true; }
  ------------------
  |  Branch (15559:13): [True: 46, False: 1.54k]
  ------------------
15560|       |
15561|  1.54k|        check_if_range(req, etag, mtime);
15562|       |
15563|  1.54k|        auto mm = std::make_shared<detail::mmap>(path.c_str());
15564|  1.54k|        if (!mm->is_open()) {
  ------------------
  |  Branch (15564:13): [True: 0, False: 1.54k]
  ------------------
15565|      0|          output_error_log(Error::OpenFile, &req);
15566|      0|          return false;
15567|      0|        }
15568|       |
15569|  1.54k|        detail::set_file_content_provider(res, mm, content_type, encoding);
15570|       |
15571|  1.54k|        if (req.method != "HEAD" && file_request_handler_) {
  ------------------
  |  Branch (15571:13): [True: 1.38k, False: 163]
  |  Branch (15571:37): [True: 0, False: 1.38k]
  ------------------
15572|      0|          file_request_handler_(req, res);
15573|      0|        }
15574|       |
15575|  1.54k|        return true;
15576|  1.54k|      } else {
15577|      0|        output_error_log(Error::OpenFile, &req);
15578|      0|      }
15579|  1.59k|    }
15580|  1.98k|  }
15581|    377|  return false;
15582|  1.98k|}
_ZN7httplib6detail13is_valid_pathERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6381|  3.22k|inline bool is_valid_path(const std::string &path) {
 6382|  3.22k|  if (path.empty() || path[0] != '/') { return false; }
  ------------------
  |  Branch (6382:7): [True: 13, False: 3.21k]
  |  Branch (6382:23): [True: 1.21k, False: 2.00k]
  ------------------
 6383|       |
 6384|  2.00k|  auto beg = size_t{1};
 6385|   177k|  for (auto i = beg; i <= path.size(); i++) {
  ------------------
  |  Branch (6385:22): [True: 175k, False: 1.98k]
  ------------------
 6386|   175k|    if (i < path.size() && path[i] != '/') {
  ------------------
  |  Branch (6386:9): [True: 173k, False: 1.98k]
  |  Branch (6386:28): [True: 168k, False: 5.15k]
  ------------------
 6387|   168k|      if (path[i] == '\0' || path[i] == '\\') { return false; }
  ------------------
  |  Branch (6387:11): [True: 1, False: 168k]
  |  Branch (6387:30): [True: 1, False: 168k]
  ------------------
 6388|       |#ifdef _WIN32
 6389|       |      if (path[i] == ':') { return false; }
 6390|       |#endif
 6391|   168k|      continue;
 6392|   168k|    }
 6393|  7.13k|    auto len = i - beg;
 6394|  7.13k|    if ((len == 0 && i < path.size()) ||
  ------------------
  |  Branch (6394:10): [True: 227, False: 6.91k]
  |  Branch (6394:22): [True: 21, False: 206]
  ------------------
 6395|  7.11k|        (len > 0 && (path[i - 1] == '.' || path[i - 1] == ' '))) {
  ------------------
  |  Branch (6395:10): [True: 6.91k, False: 206]
  |  Branch (6395:22): [True: 2, False: 6.90k]
  |  Branch (6395:44): [True: 1, False: 6.90k]
  ------------------
 6396|     24|      return false;
 6397|     24|    }
 6398|  7.11k|    beg = i + 1;
 6399|  7.11k|  }
 6400|  1.98k|  return true;
 6401|  2.00k|}
_ZN7httplib6detail19is_path_within_baseERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_:
 6448|  1.60k|                                const std::string &resolved_base) {
 6449|       |#if defined(_WIN32)
 6450|       |  return _strnicmp(resolved_path.c_str(), resolved_base.c_str(),
 6451|       |                   resolved_base.size()) == 0;
 6452|       |#else
 6453|  1.60k|  return strncmp(resolved_path.c_str(), resolved_base.c_str(),
 6454|  1.60k|                 resolved_base.size()) == 0;
 6455|  1.60k|#endif
 6456|  1.60k|}
_ZN7httplib8Response12set_redirectERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi:
13167|      6|inline void Response::set_redirect(const std::string &url, int stat) {
13168|      6|  if (detail::fields::is_field_value(url)) {
  ------------------
  |  Branch (13168:7): [True: 6, False: 0]
  ------------------
13169|      6|    set_header("Location", url);
13170|      6|    if (300 <= stat && stat < 400) {
  ------------------
  |  Branch (13170:9): [True: 6, False: 0]
  |  Branch (13170:24): [True: 6, False: 0]
  ------------------
13171|      6|      this->status = stat;
13172|      6|    } else {
13173|      0|      this->status = StatusCode::Found_302;
13174|      0|    }
13175|      6|  }
13176|      6|}
_ZN7httplib21encode_path_componentERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE:
12621|      6|inline std::string encode_path_component(const std::string &component) {
12622|      6|  std::string result;
12623|      6|  result.reserve(component.size() * 3);
12624|       |
12625|     24|  for (size_t i = 0; i < component.size(); i++) {
  ------------------
  |  Branch (12625:22): [True: 18, False: 6]
  ------------------
12626|     18|    auto c = static_cast<unsigned char>(component[i]);
12627|       |
12628|       |    // Unreserved characters per RFC 3986: ALPHA / DIGIT / "-" / "." / "_" / "~"
12629|     18|    if (detail::is_ascii_alnum(static_cast<char>(c)) || c == '-' || c == '.' ||
  ------------------
  |  Branch (12629:9): [True: 18, False: 0]
  |  Branch (12629:57): [True: 0, False: 0]
  |  Branch (12629:69): [True: 0, False: 0]
  ------------------
12630|     18|        c == '_' || c == '~') {
  ------------------
  |  Branch (12630:9): [True: 0, False: 0]
  |  Branch (12630:21): [True: 0, False: 0]
  ------------------
12631|     18|      result += static_cast<char>(c);
12632|     18|    }
12633|       |    // Path-safe sub-delimiters: "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" /
12634|       |    // "," / ";" / "="
12635|      0|    else if (c == '!' || c == '$' || c == '&' || c == '\'' || c == '(' ||
  ------------------
  |  Branch (12635:14): [True: 0, False: 0]
  |  Branch (12635:26): [True: 0, False: 0]
  |  Branch (12635:38): [True: 0, False: 0]
  |  Branch (12635:50): [True: 0, False: 0]
  |  Branch (12635:63): [True: 0, False: 0]
  ------------------
12636|      0|             c == ')' || c == '*' || c == '+' || c == ',' || c == ';' ||
  ------------------
  |  Branch (12636:14): [True: 0, False: 0]
  |  Branch (12636:26): [True: 0, False: 0]
  |  Branch (12636:38): [True: 0, False: 0]
  |  Branch (12636:50): [True: 0, False: 0]
  |  Branch (12636:62): [True: 0, False: 0]
  ------------------
12637|      0|             c == '=') {
  ------------------
  |  Branch (12637:14): [True: 0, False: 0]
  ------------------
12638|      0|      result += static_cast<char>(c);
12639|      0|    }
12640|       |    // Colon is allowed in path segments except first segment
12641|      0|    else if (c == ':') {
  ------------------
  |  Branch (12641:14): [True: 0, False: 0]
  ------------------
12642|      0|      result += static_cast<char>(c);
12643|      0|    }
12644|       |    // @ is allowed in path
12645|      0|    else if (c == '@') {
  ------------------
  |  Branch (12645:14): [True: 0, False: 0]
  ------------------
12646|      0|      result += static_cast<char>(c);
12647|      0|    } else {
12648|      0|      result += '%';
12649|      0|      char hex[3];
12650|      0|      snprintf(hex, sizeof(hex), "%02X", c);
12651|      0|      result.append(hex, 2);
12652|      0|    }
12653|     18|  }
12654|      6|  return result;
12655|      6|}
_ZNK7httplib6detail8FileStat7is_fileEv:
 6466|  3.18k|inline bool FileStat::is_file() const {
 6467|  3.18k|  return ret_ >= 0 && S_ISREG(st_.st_mode);
  ------------------
  |  Branch (6467:10): [True: 3.18k, False: 0]
  |  Branch (6467:23): [True: 3.18k, False: 0]
  ------------------
 6468|  3.18k|}
_ZNK7httplib6detail8FileStat4sizeEv:
 6478|  1.59k|inline size_t FileStat::size() const {
 6479|  1.59k|  return ret_ >= 0 ? static_cast<size_t>(st_.st_size) : 0;
  ------------------
  |  Branch (6479:10): [True: 1.59k, False: 0]
  ------------------
 6480|  1.59k|}
_ZN7httplib6detail12compute_etagERKNS0_8FileStatERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 5830|  1.59k|                                const std::string &suffix = std::string()) {
 5831|  1.59k|  if (!fs.is_file()) { return std::string(); }
  ------------------
  |  Branch (5831:7): [True: 0, False: 1.59k]
  ------------------
 5832|       |
 5833|       |  // If mtime cannot be determined (negative value indicates an error
 5834|       |  // or sentinel), do not generate an ETag. Returning a neutral / fixed
 5835|       |  // value like 0 could collide with a real file that legitimately has
 5836|       |  // mtime == 0 (epoch) and lead to misleading validators.
 5837|  1.59k|  auto mtime_raw = fs.mtime();
 5838|  1.59k|  if (mtime_raw < 0) { return std::string(); }
  ------------------
  |  Branch (5838:7): [True: 0, False: 1.59k]
  ------------------
 5839|       |
 5840|  1.59k|  auto mtime = static_cast<size_t>(mtime_raw);
 5841|  1.59k|  auto size = fs.size();
 5842|       |
 5843|  1.59k|  return std::string("W/\"") + from_i_to_hex(mtime) + "-" +
 5844|  1.59k|         from_i_to_hex(size) + suffix + "\"";
 5845|  1.59k|}
_ZNK7httplib6detail8FileStat5mtimeEv:
 6473|  3.18k|inline time_t FileStat::mtime() const {
 6474|  3.18k|  return ret_ >= 0 ? static_cast<time_t>(st_.st_mtime)
  ------------------
  |  Branch (6474:10): [True: 3.18k, False: 0]
  ------------------
 6475|  3.18k|                   : static_cast<time_t>(-1);
 6476|  3.18k|}
_ZN7httplib6detail23file_mtime_to_http_dateEl:
 5850|  1.59k|inline std::string file_mtime_to_http_date(time_t mtime) {
 5851|  1.59k|  if (mtime < 0) { return std::string(); }
  ------------------
  |  Branch (5851:7): [True: 0, False: 1.59k]
  ------------------
 5852|       |
 5853|  1.59k|  struct tm tm_buf;
 5854|       |#ifdef _WIN32
 5855|       |  if (gmtime_s(&tm_buf, &mtime) != 0) { return std::string(); }
 5856|       |#else
 5857|  1.59k|  if (gmtime_r(&mtime, &tm_buf) == nullptr) { return std::string(); }
  ------------------
  |  Branch (5857:7): [True: 0, False: 1.59k]
  ------------------
 5858|  1.59k|#endif
 5859|  1.59k|  char buf[64];
 5860|  1.59k|  if (strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S GMT", &tm_buf) == 0) {
  ------------------
  |  Branch (5860:7): [True: 0, False: 1.59k]
  ------------------
 5861|      0|    return std::string();
 5862|      0|  }
 5863|       |
 5864|  1.59k|  return std::string(buf);
 5865|  1.59k|}
_ZNK7httplib6Server21check_if_not_modifiedERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEl:
15586|  1.59k|                                          time_t mtime) const {
15587|       |  // Handle conditional GET:
15588|       |  // 1. If-None-Match takes precedence (RFC 9110 Section 13.1.2)
15589|       |  // 2. If-Modified-Since is checked only when If-None-Match is absent
15590|  1.59k|  if (req.has_header("If-None-Match")) {
  ------------------
  |  Branch (15590:7): [True: 129, False: 1.46k]
  ------------------
15591|    129|    if (!etag.empty()) {
  ------------------
  |  Branch (15591:9): [True: 129, False: 0]
  ------------------
15592|    129|      auto val =
15593|    129|          detail::get_combined_header_value(req.headers, "If-None-Match");
15594|       |
15595|       |      // NOTE: We use exact string matching here. This works correctly
15596|       |      // because our server always generates weak ETags (W/"..."), and
15597|       |      // clients typically send back the same ETag they received.
15598|       |      // RFC 9110 Section 8.8.3.2 allows weak comparison for
15599|       |      // If-None-Match, where W/"x" and "x" would match, but this
15600|       |      // simplified implementation requires exact matches.
15601|    129|      auto ret = detail::split_find(val.data(), val.data() + val.size(), ',',
15602|    129|                                    [&](const char *b, const char *e) {
15603|    129|                                      auto seg_len = static_cast<size_t>(e - b);
15604|    129|                                      return (seg_len == 1 && *b == '*') ||
15605|    129|                                             (seg_len == etag.size() &&
15606|    129|                                              std::equal(b, e, etag.begin()));
15607|    129|                                    });
15608|       |
15609|    129|      if (ret) {
  ------------------
  |  Branch (15609:11): [True: 5, False: 124]
  ------------------
15610|      5|        res.status = StatusCode::NotModified_304;
15611|      5|        return true;
15612|      5|      }
15613|    129|    }
15614|  1.46k|  } else if (req.has_header("If-Modified-Since")) {
  ------------------
  |  Branch (15614:14): [True: 115, False: 1.34k]
  ------------------
15615|    115|    auto val = req.get_header_value("If-Modified-Since");
15616|    115|    auto t = detail::parse_http_date(val);
15617|       |
15618|    115|    if (t != static_cast<time_t>(-1) && mtime <= t) {
  ------------------
  |  Branch (15618:9): [True: 97, False: 18]
  |  Branch (15618:41): [True: 41, False: 56]
  ------------------
15619|     41|      res.status = StatusCode::NotModified_304;
15620|     41|      return true;
15621|     41|    }
15622|    115|  }
15623|  1.54k|  return false;
15624|  1.59k|}
_ZZNK7httplib6Server21check_if_not_modifiedERKNS_7RequestERNS_8ResponseERKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEElENKUlPKcSG_E_clESG_SG_:
15602|   182k|                                    [&](const char *b, const char *e) {
15603|   182k|                                      auto seg_len = static_cast<size_t>(e - b);
15604|   182k|                                      return (seg_len == 1 && *b == '*') ||
  ------------------
  |  Branch (15604:47): [True: 53.0k, False: 129k]
  |  Branch (15604:63): [True: 5, False: 53.0k]
  ------------------
15605|   182k|                                             (seg_len == etag.size() &&
  ------------------
  |  Branch (15605:47): [True: 992, False: 181k]
  ------------------
15606|    992|                                              std::equal(b, e, etag.begin()));
  ------------------
  |  Branch (15606:47): [True: 0, False: 992]
  ------------------
15607|   182k|                                    });
_ZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5868|    307|inline time_t parse_http_date(const std::string &date_str) {
 5869|    307|  struct tm tm_buf;
 5870|       |
 5871|       |  // Create a classic locale object once for all parsing attempts
 5872|    307|  const std::locale classic_locale = std::locale::classic();
 5873|       |
 5874|       |  // Try to parse using std::get_time (C++11, cross-platform)
 5875|    307|  auto try_parse = [&](const char *fmt) -> bool {
 5876|    307|    std::istringstream ss(date_str);
 5877|    307|    ss.imbue(classic_locale);
 5878|       |
 5879|    307|    memset(&tm_buf, 0, sizeof(tm_buf));
 5880|    307|    ss >> std::get_time(&tm_buf, fmt);
 5881|       |
 5882|    307|    return !ss.fail();
 5883|    307|  };
 5884|       |
 5885|       |  // RFC 9110 preferred format (HTTP-date): "Sun, 06 Nov 1994 08:49:37 GMT"
 5886|    307|  if (!try_parse("%a, %d %b %Y %H:%M:%S")) {
  ------------------
  |  Branch (5886:7): [True: 112, False: 195]
  ------------------
 5887|       |    // RFC 850 format: "Sunday, 06-Nov-94 08:49:37 GMT"
 5888|    112|    if (!try_parse("%A, %d-%b-%y %H:%M:%S")) {
  ------------------
  |  Branch (5888:9): [True: 111, False: 1]
  ------------------
 5889|       |      // asctime format: "Sun Nov  6 08:49:37 1994"
 5890|    111|      if (!try_parse("%a %b %d %H:%M:%S %Y")) {
  ------------------
  |  Branch (5890:11): [True: 108, False: 3]
  ------------------
 5891|    108|        return static_cast<time_t>(-1);
 5892|    108|      }
 5893|    111|    }
 5894|    112|  }
 5895|       |
 5896|       |#ifdef _WIN32
 5897|       |  return _mkgmtime(&tm_buf);
 5898|       |#elif defined _AIX
 5899|       |  return mktime(&tm_buf);
 5900|       |#else
 5901|    199|  return timegm(&tm_buf);
 5902|    307|#endif
 5903|    307|}
_ZZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEENKUlPKcE_clESB_:
 5875|    530|  auto try_parse = [&](const char *fmt) -> bool {
 5876|    530|    std::istringstream ss(date_str);
 5877|    530|    ss.imbue(classic_locale);
 5878|       |
 5879|    530|    memset(&tm_buf, 0, sizeof(tm_buf));
 5880|    530|    ss >> std::get_time(&tm_buf, fmt);
 5881|       |
 5882|    530|    return !ss.fail();
 5883|    530|  };
_ZNK7httplib6Server14check_if_rangeERNS_7RequestERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEl:
15627|  1.54k|                                   time_t mtime) const {
15628|       |  // Handle If-Range for partial content requests (RFC 9110
15629|       |  // Section 13.1.5). If-Range is only evaluated when Range header is
15630|       |  // present. If the validator matches, serve partial content; otherwise
15631|       |  // serve full content.
15632|  1.54k|  if (!req.ranges.empty() && req.has_header("If-Range")) {
  ------------------
  |  Branch (15632:7): [True: 769, False: 778]
  |  Branch (15632:7): [True: 194, False: 1.35k]
  |  Branch (15632:30): [True: 194, False: 575]
  ------------------
15633|    194|    auto val = req.get_header_value("If-Range");
15634|       |
15635|    194|    auto is_valid_range = [&]() {
15636|    194|      if (detail::is_strong_etag(val)) {
15637|       |        // RFC 9110 Section 13.1.5: If-Range requires strong ETag
15638|       |        // comparison.
15639|    194|        return (!etag.empty() && val == etag);
15640|    194|      } else if (detail::is_weak_etag(val)) {
15641|       |        // Weak ETags are not valid for If-Range (RFC 9110 Section 13.1.5)
15642|    194|        return false;
15643|    194|      } else {
15644|       |        // HTTP-date comparison
15645|    194|        auto t = detail::parse_http_date(val);
15646|    194|        return (t != static_cast<time_t>(-1) && mtime <= t);
15647|    194|      }
15648|    194|    };
15649|       |
15650|    194|    if (!is_valid_range()) {
  ------------------
  |  Branch (15650:9): [True: 157, False: 37]
  ------------------
15651|       |      // Validator doesn't match: ignore Range and serve full content
15652|    157|      req.ranges.clear();
15653|    157|      return false;
15654|    157|    }
15655|    194|  }
15656|       |
15657|  1.39k|  return true;
15658|  1.54k|}
_ZZNK7httplib6Server14check_if_rangeERNS_7RequestERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEElENKUlvE_clEv:
15635|    194|    auto is_valid_range = [&]() {
15636|    194|      if (detail::is_strong_etag(val)) {
  ------------------
  |  Branch (15636:11): [True: 1, False: 193]
  ------------------
15637|       |        // RFC 9110 Section 13.1.5: If-Range requires strong ETag
15638|       |        // comparison.
15639|      1|        return (!etag.empty() && val == etag);
  ------------------
  |  Branch (15639:17): [True: 1, False: 0]
  |  Branch (15639:34): [True: 0, False: 1]
  ------------------
15640|    193|      } else if (detail::is_weak_etag(val)) {
  ------------------
  |  Branch (15640:18): [True: 1, False: 192]
  ------------------
15641|       |        // Weak ETags are not valid for If-Range (RFC 9110 Section 13.1.5)
15642|      1|        return false;
15643|    192|      } else {
15644|       |        // HTTP-date comparison
15645|    192|        auto t = detail::parse_http_date(val);
15646|    192|        return (t != static_cast<time_t>(-1) && mtime <= t);
  ------------------
  |  Branch (15646:17): [True: 102, False: 90]
  |  Branch (15646:49): [True: 37, False: 65]
  ------------------
15647|    192|      }
15648|    194|    };
_ZN7httplib6detail14is_strong_etagERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5910|    194|inline bool is_strong_etag(const std::string &s) {
 5911|       |  // Check if the string is a strong ETag (starts and ends with '"', at least 2
 5912|       |  // chars)
 5913|    194|  return s.size() >= 2 && s[0] == '"' && s.back() == '"';
  ------------------
  |  Branch (5913:10): [True: 189, False: 5]
  |  Branch (5913:27): [True: 17, False: 172]
  |  Branch (5913:42): [True: 1, False: 16]
  ------------------
 5914|    194|}
_ZN7httplib6detail12is_weak_etagERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5905|    193|inline bool is_weak_etag(const std::string &s) {
 5906|       |  // Check if the string is a weak ETag (starts with 'W/"')
 5907|    193|  return s.size() > 3 && s[0] == 'W' && s[1] == '/' && s[2] == '"';
  ------------------
  |  Branch (5907:10): [True: 161, False: 32]
  |  Branch (5907:26): [True: 28, False: 133]
  |  Branch (5907:41): [True: 11, False: 17]
  |  Branch (5907:56): [True: 1, False: 10]
  ------------------
 5908|    193|}
_ZN7httplib6detail14expect_contentERKNS_7RequestE:
11187|  1.63k|inline bool expect_content(const Request &req) {
11188|  1.63k|  if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" ||
  ------------------
  |  Branch (11188:7): [True: 1, False: 1.63k]
  |  Branch (11188:31): [True: 8, False: 1.63k]
  |  Branch (11188:54): [True: 1, False: 1.62k]
  ------------------
11189|  1.62k|      req.method == "DELETE") {
  ------------------
  |  Branch (11189:7): [True: 1, False: 1.62k]
  ------------------
11190|     11|    return true;
11191|     11|  }
11192|  1.62k|  return has_framed_body(req);
11193|  1.63k|}
_ZN7httplib13ContentReaderC2ENSt3__18functionIFbNS2_IFbPKcmEEEEEENS2_IFbNS2_IFbRKNS_8FormDataEEEES6_EEE:
 1730|    175|      : reader_(std::move(reader)),
 1731|    175|        formdata_reader_(std::move(multipart_reader)) {}
_ZNK7httplib6Server35dispatch_request_for_content_readerERNS_7RequestERNS_8ResponseENS_13ContentReaderERKNSt3__16vectorINS6_4pairINS6_10unique_ptrINS_6detail11MatcherBaseENS6_14default_deleteISB_EEEENS6_8functionIFvRKS1_S4_RKS5_EEEEENS6_9allocatorISM_EEEE:
16115|     11|    const HandlersForContentReader &handlers) const {
16116|     11|  for (const auto &x : handlers) {
  ------------------
  |  Branch (16116:22): [True: 0, False: 11]
  ------------------
16117|      0|    const auto &matcher = x.first;
16118|      0|    const auto &handler = x.second;
16119|       |
16120|      0|    if (matcher->match(req)) {
  ------------------
  |  Branch (16120:9): [True: 0, False: 0]
  ------------------
16121|      0|      req.matched_route = matcher->pattern();
16122|      0|      if (!pre_request_handler_ ||
  ------------------
  |  Branch (16122:11): [True: 0, False: 0]
  ------------------
16123|      0|          pre_request_handler_(req, res) != HandlerResponse::Handled) {
  ------------------
  |  Branch (16123:11): [True: 0, False: 0]
  ------------------
16124|      0|        handler(req, res, content_reader);
16125|      0|      }
16126|      0|      return true;
16127|      0|    }
16128|      0|  }
16129|     11|  return false;
16130|     11|}
_ZN7httplib6Server16dispatch_requestERNS_7RequestERNS_8ResponseERKNSt3__16vectorINS5_4pairINS5_10unique_ptrINS_6detail11MatcherBaseENS5_14default_deleteISA_EEEENS5_8functionIFvRKS1_S4_EEEEENS5_9allocatorISJ_EEEERNS_6StreamE:
15929|  1.63k|                                     const Handlers &handlers, Stream &strm) {
15930|  1.63k|  for (const auto &x : handlers) {
  ------------------
  |  Branch (15930:22): [True: 0, False: 1.63k]
  ------------------
15931|      0|    const auto &matcher = x.first;
15932|      0|    const auto &handler = x.second;
15933|       |
15934|      0|    if (matcher->match(req)) {
  ------------------
  |  Branch (15934:9): [True: 0, False: 0]
  ------------------
15935|      0|      req.matched_route = matcher->pattern();
15936|       |
15937|       |      // Run the pre-request handler before reading the body so a rejected
15938|       |      // request (e.g. failed authentication) never forces us to buffer a
15939|       |      // potentially large body. `req.matched_route` is available here.
15940|      0|      if (pre_request_handler_ &&
  ------------------
  |  Branch (15940:11): [True: 0, False: 0]
  ------------------
15941|      0|          pre_request_handler_(req, res) == HandlerResponse::Handled) {
  ------------------
  |  Branch (15941:11): [True: 0, False: 0]
  ------------------
15942|      0|        return true;
15943|      0|      }
15944|       |
15945|       |      // The route matched and the request was approved; read the body now.
15946|      0|      if (detail::expect_content(req) && !read_content(strm, req, res)) {
  ------------------
  |  Branch (15946:11): [True: 0, False: 0]
  |  Branch (15946:42): [True: 0, False: 0]
  ------------------
15947|      0|        output_error_log(Error::Read, &req);
15948|      0|        return false;
15949|      0|      }
15950|       |
15951|      0|      handler(req, res);
15952|      0|      return true;
15953|      0|    }
15954|      0|  }
15955|  1.63k|  return false;
15956|  1.63k|}
_ZN7httplib6detail20prefer_assigned_bodyERNS_8ResponseE:
13063|  7.32k|inline void prefer_assigned_body(Response &res) {
13064|  7.32k|  if (!res.body.empty() &&
  ------------------
  |  Branch (13064:7): [True: 0, False: 7.32k]
  ------------------
13065|      0|      (res.content_provider_ || !res.file_content_path_.empty())) {
  ------------------
  |  Branch (13065:8): [True: 0, False: 0]
  |  Branch (13065:33): [True: 0, False: 0]
  ------------------
13066|      0|    clear_content_provider(res);
13067|      0|  }
13068|  7.32k|}
_ZN7httplib6detail4mmapC2EPKc:
 6976|  1.54k|inline mmap::mmap(const char *path) { open(path); }
_ZN7httplib6detail4mmap4openEPKc:
 6980|  1.54k|inline bool mmap::open(const char *path) {
 6981|  1.54k|  close();
 6982|       |
 6983|       |#if defined(_WIN32)
 6984|       |  auto wpath = u8string_to_wstring(path);
 6985|       |  if (wpath.empty()) { return false; }
 6986|       |
 6987|       |  hFile_ =
 6988|       |      ::CreateFile2(wpath.c_str(), GENERIC_READ,
 6989|       |                    FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, NULL);
 6990|       |
 6991|       |  if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
 6992|       |
 6993|       |  LARGE_INTEGER size{};
 6994|       |  if (!::GetFileSizeEx(hFile_, &size)) { return false; }
 6995|       |  // If the following line doesn't compile due to QuadPart, update Windows SDK.
 6996|       |  // See:
 6997|       |  // https://github.com/yhirose/cpp-httplib/issues/1903#issuecomment-2316520721
 6998|       |  if (!fits_in_size_t(static_cast<uint64_t>(size.QuadPart))) { return false; }
 6999|       |  size_ = static_cast<size_t>(size.QuadPart);
 7000|       |
 7001|       |  hMapping_ =
 7002|       |      ::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
 7003|       |
 7004|       |  // Special treatment for an empty file...
 7005|       |  if (hMapping_ == NULL && size_ == 0) {
 7006|       |    close();
 7007|       |    is_open_empty_file = true;
 7008|       |    return true;
 7009|       |  }
 7010|       |
 7011|       |  if (hMapping_ == NULL) {
 7012|       |    close();
 7013|       |    return false;
 7014|       |  }
 7015|       |
 7016|       |  addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
 7017|       |
 7018|       |  if (addr_ == nullptr) {
 7019|       |    close();
 7020|       |    return false;
 7021|       |  }
 7022|       |#else
 7023|       |  // O_NONBLOCK so that opening a FIFO does not wait for a writer.
 7024|  1.54k|  fd_ = ::open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
 7025|  1.54k|  if (fd_ == -1) { return false; }
  ------------------
  |  Branch (7025:7): [True: 0, False: 1.54k]
  ------------------
 7026|       |
 7027|       |  // Only a regular file has a size to serve, unlike a directory or a device.
 7028|  1.54k|  struct stat sb;
 7029|  1.54k|  if (fstat(fd_, &sb) == -1 || !S_ISREG(sb.st_mode) ||
  ------------------
  |  Branch (7029:7): [True: 0, False: 1.54k]
  |  Branch (7029:32): [True: 0, False: 1.54k]
  ------------------
 7030|  1.54k|      !fits_in_size_t(static_cast<uint64_t>(sb.st_size))) {
  ------------------
  |  Branch (7030:7): [True: 0, False: 1.54k]
  ------------------
 7031|      0|    close();
 7032|      0|    return false;
 7033|      0|  }
 7034|  1.54k|  size_ = static_cast<size_t>(sb.st_size);
 7035|  1.54k|#endif
 7036|       |
 7037|  1.54k|  return true;
 7038|  1.54k|}
_ZN7httplib6detail4mmap5closeEv:
 7050|  3.09k|inline void mmap::close() {
 7051|       |#if defined(_WIN32)
 7052|       |  if (addr_) {
 7053|       |    ::UnmapViewOfFile(addr_);
 7054|       |    addr_ = nullptr;
 7055|       |  }
 7056|       |
 7057|       |  if (hMapping_) {
 7058|       |    ::CloseHandle(hMapping_);
 7059|       |    hMapping_ = NULL;
 7060|       |  }
 7061|       |
 7062|       |  if (hFile_ != INVALID_HANDLE_VALUE) {
 7063|       |    ::CloseHandle(hFile_);
 7064|       |    hFile_ = INVALID_HANDLE_VALUE;
 7065|       |  }
 7066|       |
 7067|       |  is_open_empty_file = false;
 7068|       |#else
 7069|  3.09k|  if (fd_ != -1) {
  ------------------
  |  Branch (7069:7): [True: 1.54k, False: 1.54k]
  ------------------
 7070|  1.54k|    ::close(fd_);
 7071|  1.54k|    fd_ = -1;
 7072|  1.54k|  }
 7073|  3.09k|#endif
 7074|  3.09k|  size_ = 0;
 7075|  3.09k|}
_ZN7httplib6detail4mmapD2Ev:
 6978|  1.54k|inline mmap::~mmap() { close(); }
_ZNK7httplib6detail4mmap7is_openEv:
 7040|  1.54k|inline bool mmap::is_open() const {
 7041|       |#if defined(_WIN32)
 7042|       |  return is_open_empty_file ? true : addr_ != nullptr;
 7043|       |#else
 7044|  1.54k|  return fd_ != -1;
 7045|  1.54k|#endif
 7046|  1.54k|}
_ZNK7httplib8Response16get_header_valueERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPKcm:
13142|  1.74k|                                              size_t id) const {
13143|  1.74k|  return detail::get_header_value(headers, key, def, id);
13144|  1.74k|}
_ZN7httplib6detail17find_content_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERKNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEES9_:
 8527|  1.59k|                  const std::string &default_content_type) {
 8528|       |  // Extensions are matched regardless of case, as web servers do
 8529|  1.59k|  auto ext = case_ignore::to_lower(file_extension(path));
 8530|       |
 8531|  1.59k|  auto it = user_data.find(ext);
 8532|  1.59k|  if (it != user_data.end()) { return it->second; }
  ------------------
  |  Branch (8532:7): [True: 0, False: 1.59k]
  ------------------
 8533|       |
 8534|  1.59k|  static const struct {
 8535|  1.59k|    const char *ext;
 8536|  1.59k|    const char *type;
 8537|  1.59k|  } types[] = {
 8538|  1.59k|      {"css", "text/css"},
 8539|  1.59k|      {"csv", "text/csv"},
 8540|  1.59k|      {"htm", "text/html"},
 8541|  1.59k|      {"html", "text/html"},
 8542|  1.59k|      {"js", "text/javascript"},
 8543|  1.59k|      {"mjs", "text/javascript"},
 8544|  1.59k|      {"txt", "text/plain"},
 8545|  1.59k|      {"vtt", "text/vtt"},
 8546|       |
 8547|  1.59k|      {"apng", "image/apng"},
 8548|  1.59k|      {"avif", "image/avif"},
 8549|  1.59k|      {"bmp", "image/bmp"},
 8550|  1.59k|      {"gif", "image/gif"},
 8551|  1.59k|      {"png", "image/png"},
 8552|  1.59k|      {"svg", "image/svg+xml"},
 8553|  1.59k|      {"webp", "image/webp"},
 8554|  1.59k|      {"ico", "image/x-icon"},
 8555|  1.59k|      {"tif", "image/tiff"},
 8556|  1.59k|      {"tiff", "image/tiff"},
 8557|  1.59k|      {"jpg", "image/jpeg"},
 8558|  1.59k|      {"jpeg", "image/jpeg"},
 8559|       |
 8560|  1.59k|      {"mp4", "video/mp4"},
 8561|  1.59k|      {"mpeg", "video/mpeg"},
 8562|  1.59k|      {"webm", "video/webm"},
 8563|       |
 8564|  1.59k|      {"mp3", "audio/mp3"},
 8565|  1.59k|      {"mpga", "audio/mpeg"},
 8566|  1.59k|      {"weba", "audio/webm"},
 8567|  1.59k|      {"wav", "audio/wave"},
 8568|       |
 8569|  1.59k|      {"otf", "font/otf"},
 8570|  1.59k|      {"ttf", "font/ttf"},
 8571|  1.59k|      {"woff", "font/woff"},
 8572|  1.59k|      {"woff2", "font/woff2"},
 8573|       |
 8574|  1.59k|      {"7z", "application/x-7z-compressed"},
 8575|  1.59k|      {"atom", "application/atom+xml"},
 8576|  1.59k|      {"pdf", "application/pdf"},
 8577|  1.59k|      {"json", "application/json"},
 8578|  1.59k|      {"rss", "application/rss+xml"},
 8579|  1.59k|      {"tar", "application/x-tar"},
 8580|  1.59k|      {"xht", "application/xhtml+xml"},
 8581|  1.59k|      {"xhtml", "application/xhtml+xml"},
 8582|  1.59k|      {"xslt", "application/xslt+xml"},
 8583|  1.59k|      {"xml", "application/xml"},
 8584|  1.59k|      {"gz", "application/gzip"},
 8585|  1.59k|      {"zip", "application/zip"},
 8586|  1.59k|      {"wasm", "application/wasm"},
 8587|  1.59k|  };
 8588|       |
 8589|  6.58k|  for (const auto &t : types) {
  ------------------
  |  Branch (8589:22): [True: 6.58k, False: 4]
  ------------------
 8590|  6.58k|    if (ext == t.ext) { return t.type; }
  ------------------
  |  Branch (8590:9): [True: 1.58k, False: 5.00k]
  ------------------
 8591|  6.58k|  }
 8592|      4|  return default_content_type;
 8593|  1.59k|}
_ZN7httplib6detail14file_extensionERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6514|  1.59k|inline std::string file_extension(const std::string &path) {
 6515|  1.59k|  auto i = path.size();
 6516|  7.94k|  while (i > 0 && is_ascii_alnum(path[i - 1])) {
  ------------------
  |  Branch (6516:10): [True: 7.94k, False: 0]
  |  Branch (6516:19): [True: 6.34k, False: 1.59k]
  ------------------
 6517|  6.34k|    i--;
 6518|  6.34k|  }
 6519|  1.59k|  if (i == path.size() || i == 0 || path[i - 1] != '.') {
  ------------------
  |  Branch (6519:7): [True: 0, False: 1.59k]
  |  Branch (6519:27): [True: 0, False: 1.59k]
  |  Branch (6519:37): [True: 0, False: 1.59k]
  ------------------
 6520|      0|    return std::string();
 6521|      0|  }
 6522|  1.59k|  return path.substr(i);
 6523|  1.59k|}
_ZN7httplib6detail25set_file_content_providerERNS_8ResponseERKNSt3__110shared_ptrINS0_4mmapEEERKNS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_12EncodingTypeE:
 9909|  1.54k|                                      EncodingType encoding) {
 9910|       |  // One read and one write move up to this much of the file at a time.
 9911|  1.54k|  auto buf = std::make_shared<std::vector<char>>(
 9912|  1.54k|      (std::min)(m->size(), size_t(256 * 1024)));
 9913|  1.54k|  res.set_content_provider(
 9914|  1.54k|      m->size(), content_type,
 9915|  1.54k|      [m, buf](size_t offset, size_t length, DataSink &sink) -> bool {
 9916|       |        // Never read past the file, which ends the response early if it has
 9917|       |        // shrunk since it was opened.
 9918|  1.54k|        auto n = m->read(offset, buf->data(), (std::min)(length, buf->size()));
 9919|  1.54k|        if (n == 0) { return false; }
 9920|  1.54k|        sink.write(buf->data(), n);
 9921|  1.54k|        return true;
 9922|  1.54k|      });
 9923|       |
 9924|  1.54k|  res.is_file_content_provider_ = true;
 9925|  1.54k|  res.content_coding_ = encoding;
 9926|  1.54k|}
_ZN7httplib8Response20set_content_providerEmRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_8functionIFbmmRNS_8DataSinkEEEENSA_IFvbEEE:
13199|  1.54k|    ContentProviderResourceReleaser resource_releaser) {
13200|  1.54k|  detail::clear_content(*this);
13201|  1.54k|  detail::set_content_type(*this, content_type);
13202|       |
13203|  1.54k|  content_length_ = in_length;
13204|  1.54k|  if (in_length > 0) { content_provider_ = std::move(provider); }
  ------------------
  |  Branch (13204:7): [True: 1.54k, False: 0]
  ------------------
13205|  1.54k|  content_provider_resource_releaser_ = std::move(resource_releaser);
13206|  1.54k|}
_ZN7httplib6detail16set_content_typeERNS_8ResponseERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
13056|  1.54k|inline void set_content_type(Response &res, const std::string &content_type) {
13057|  1.54k|  res.headers.erase("Content-Type");
13058|  1.54k|  res.set_header("Content-Type", content_type);
13059|  1.54k|}
_ZZN7httplib6detail25set_file_content_providerERNS_8ResponseERKNSt3__110shared_ptrINS0_4mmapEEERKNS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_12EncodingTypeEENKUlmmRNS_8DataSinkEE_clEmmSJ_:
 9915|  1.46k|      [m, buf](size_t offset, size_t length, DataSink &sink) -> bool {
 9916|       |        // Never read past the file, which ends the response early if it has
 9917|       |        // shrunk since it was opened.
 9918|  1.46k|        auto n = m->read(offset, buf->data(), (std::min)(length, buf->size()));
 9919|  1.46k|        if (n == 0) { return false; }
  ------------------
  |  Branch (9919:13): [True: 0, False: 1.46k]
  ------------------
 9920|  1.46k|        sink.write(buf->data(), n);
 9921|  1.46k|        return true;
 9922|  1.46k|      });
_ZNK7httplib6detail4mmap4readEmPcm:
 7097|  1.46k|inline size_t mmap::read(size_t offset, char *buf, size_t len) const {
 7098|  1.46k|  if (offset >= size_) { return 0; }
  ------------------
  |  Branch (7098:7): [True: 0, False: 1.46k]
  ------------------
 7099|  1.46k|  len = (std::min)(len, size_ - offset);
 7100|       |#if defined(_WIN32)
 7101|       |  // Windows does not let a mapped file be truncated.
 7102|       |  std::memcpy(buf, static_cast<const char *>(addr_) + offset, len);
 7103|       |  return len;
 7104|       |#else
 7105|  1.46k|  auto n = handle_EINTR(
 7106|  1.46k|      [&]() { return ::pread(fd_, buf, len, static_cast<off_t>(offset)); });
 7107|  1.46k|  return n > 0 ? static_cast<size_t>(n) : 0;
  ------------------
  |  Branch (7107:10): [True: 1.46k, False: 0]
  ------------------
 7108|  1.46k|#endif
 7109|  1.46k|}
_ZN7httplib6detail12handle_EINTRIZNKS0_4mmap4readEmPcmEUlvE_EElT_:
 7084|  1.46k|template <typename T> inline ssize_t handle_EINTR(T fn) {
 7085|  1.46k|  ssize_t res = 0;
 7086|  1.46k|  while (true) {
  ------------------
  |  Branch (7086:10): [True: 1.46k, Folded]
  ------------------
 7087|  1.46k|    res = fn();
 7088|  1.46k|    if (res < 0 && errno == EINTR) {
  ------------------
  |  Branch (7088:9): [True: 0, False: 1.46k]
  |  Branch (7088:20): [True: 0, False: 0]
  ------------------
 7089|      0|      std::this_thread::sleep_for(std::chrono::microseconds{1});
 7090|      0|      continue;
 7091|      0|    }
 7092|  1.46k|    break;
 7093|  1.46k|  }
 7094|  1.46k|  return res;
 7095|  1.46k|}
_ZZNK7httplib6detail4mmap4readEmPcmENKUlvE_clEv:
 7106|  1.46k|      [&]() { return ::pread(fd_, buf, len, static_cast<off_t>(offset)); });
_ZNK7httplib6detail4mmap4sizeEv:
 7048|  3.09k|inline size_t mmap::size() const { return size_; }
_ZN7httplib6detail11range_errorERNS_7RequestERNS_8ResponseE:
10984|  1.60k|inline bool range_error(Request &req, Response &res) {
10985|  1.60k|  if (!req.ranges.empty() && 200 <= res.status && res.status < 300) {
  ------------------
  |  Branch (10985:7): [True: 617, False: 986]
  |  Branch (10985:30): [True: 617, False: 0]
  |  Branch (10985:51): [True: 612, False: 5]
  ------------------
10986|    612|    if (res.body.empty() && res.content_provider_ && res.content_length_ == 0) {
  ------------------
  |  Branch (10986:9): [True: 612, False: 0]
  |  Branch (10986:29): [True: 612, False: 0]
  |  Branch (10986:54): [True: 0, False: 612]
  ------------------
10987|      0|      req.ranges.clear();
10988|      0|      if (res.status == StatusCode::PartialContent_206) {
  ------------------
  |  Branch (10988:11): [True: 0, False: 0]
  ------------------
10989|      0|        res.status = StatusCode::OK_200;
10990|      0|      }
10991|      0|      return false;
10992|      0|    }
10993|       |
10994|    612|    ssize_t content_len = static_cast<ssize_t>(
10995|    612|        res.content_length_ ? res.content_length_ : res.body.size());
  ------------------
  |  Branch (10995:9): [True: 612, False: 0]
  ------------------
10996|       |
10997|    612|    Ranges satisfiable_ranges;
10998|    612|    size_t overwrapping_count = 0;
10999|       |
11000|       |    // NOTE: The following Range check is based on '14.2. Range' in RFC 9110
11001|       |    // 'HTTP Semantics' to avoid potential denial-of-service attacks.
11002|       |    // https://www.rfc-editor.org/rfc/rfc9110#section-14.2
11003|       |
11004|       |    // Too many ranges
11005|    612|    if (CPPHTTPLIB_RANGE_MAX_COUNT > 0 &&
  ------------------
  |  |  175|    612|#define CPPHTTPLIB_RANGE_MAX_COUNT 1024
  ------------------
  |  Branch (11005:9): [True: 612, Folded]
  ------------------
11006|    612|        req.ranges.size() > CPPHTTPLIB_RANGE_MAX_COUNT) {
  ------------------
  |  |  175|    612|#define CPPHTTPLIB_RANGE_MAX_COUNT 1024
  ------------------
  |  Branch (11006:9): [True: 1, False: 611]
  ------------------
11007|      1|      return true;
11008|      1|    }
11009|       |
11010|    611|    satisfiable_ranges.reserve(req.ranges.size());
11011|       |
11012|  1.22k|    for (auto r : req.ranges) {
  ------------------
  |  Branch (11012:17): [True: 1.22k, False: 564]
  ------------------
11013|  1.22k|      auto &first_pos = r.first;
11014|  1.22k|      auto &last_pos = r.second;
11015|       |
11016|  1.22k|      if (first_pos == -1 && last_pos == -1) {
  ------------------
  |  Branch (11016:11): [True: 507, False: 721]
  |  Branch (11016:30): [True: 0, False: 507]
  ------------------
11017|      0|        first_pos = 0;
11018|      0|        last_pos = content_len;
11019|      0|      }
11020|       |
11021|       |      // RFC 9110 14.1.2: a suffix-length longer than the representation
11022|       |      // selects the entire representation.
11023|  1.22k|      if (first_pos == -1) {
  ------------------
  |  Branch (11023:11): [True: 507, False: 721]
  ------------------
11024|    507|        first_pos = (std::max)(static_cast<ssize_t>(0), content_len - last_pos);
11025|    507|        last_pos = content_len - 1;
11026|    507|      }
11027|       |
11028|       |      // NOTE: RFC-9110 '14.1.2. Byte Ranges':
11029|       |      // A client can limit the number of bytes requested without knowing the
11030|       |      // size of the selected representation. If the last-pos value is absent,
11031|       |      // or if the value is greater than or equal to the current length of the
11032|       |      // representation data, the byte range is interpreted as the remainder of
11033|       |      // the representation (i.e., the server replaces the value of last-pos
11034|       |      // with a value that is one less than the current length of the selected
11035|       |      // representation).
11036|       |      // https://www.rfc-editor.org/rfc/rfc9110.html#section-14.1.2-6
11037|  1.22k|      if (last_pos == -1 || last_pos >= content_len) {
  ------------------
  |  Branch (11037:11): [True: 245, False: 983]
  |  Branch (11037:29): [True: 141, False: 842]
  ------------------
11038|    386|        last_pos = content_len - 1;
11039|    386|      }
11040|       |
11041|       |      // Skip an unsatisfiable range (RFC 9110 14.1.1)
11042|  1.22k|      if (!(0 <= first_pos && first_pos <= last_pos &&
  ------------------
  |  Branch (11042:13): [True: 1.22k, False: 0]
  |  Branch (11042:31): [True: 1.10k, False: 122]
  ------------------
11043|  1.10k|            last_pos <= content_len - 1)) {
  ------------------
  |  Branch (11043:13): [True: 1.10k, False: 0]
  ------------------
11044|    122|        continue;
11045|    122|      }
11046|       |
11047|       |      // Request must not have more than two overlapping ranges
11048|  1.34k|      for (const auto &prev : satisfiable_ranges) {
  ------------------
  |  Branch (11048:29): [True: 1.34k, False: 778]
  ------------------
11049|  1.34k|        if (!(last_pos < prev.first || first_pos > prev.second)) {
  ------------------
  |  Branch (11049:15): [True: 376, False: 969]
  |  Branch (11049:40): [True: 641, False: 328]
  ------------------
11050|    328|          overwrapping_count++;
11051|    328|          if (overwrapping_count > 2) { return true; }
  ------------------
  |  Branch (11051:15): [True: 47, False: 281]
  ------------------
11052|    281|          break; // Only count once per range
11053|    328|        }
11054|  1.34k|      }
11055|       |
11056|  1.05k|      satisfiable_ranges.push_back(r);
11057|  1.05k|    }
11058|       |
11059|       |    // 416 only when no range is satisfiable (RFC 9110 15.5.17)
11060|    564|    if (satisfiable_ranges.empty()) { return true; }
  ------------------
  |  Branch (11060:9): [True: 117, False: 447]
  ------------------
11061|    447|    req.ranges = std::move(satisfiable_ranges);
11062|       |
11063|       |    // After validation, coalesce overlapping ranges as per RFC 9110
11064|    447|    coalesce_ranges(req.ranges, static_cast<size_t>(content_len));
11065|    447|  }
11066|       |
11067|  1.43k|  return false;
11068|  1.60k|}
_ZN7httplib6detail15coalesce_rangesERNSt3__16vectorINS1_4pairIllEENS1_9allocatorIS4_EEEEm:
10928|    447|inline void coalesce_ranges(Ranges &ranges, size_t content_length) {
10929|    447|  if (ranges.size() <= 1) return;
  ------------------
  |  Branch (10929:7): [True: 314, False: 133]
  ------------------
10930|       |
10931|       |  // Sort ranges by start position
10932|    133|  std::sort(ranges.begin(), ranges.end(),
10933|    133|            [](const Range &a, const Range &b) { return a.first < b.first; });
10934|       |
10935|    133|  Ranges coalesced;
10936|    133|  coalesced.reserve(ranges.size());
10937|       |
10938|    578|  for (auto &r : ranges) {
  ------------------
  |  Branch (10938:16): [True: 578, False: 133]
  ------------------
10939|    578|    auto first_pos = r.first;
10940|    578|    auto last_pos = r.second;
10941|       |
10942|       |    // Handle special cases like in range_error
10943|    578|    if (first_pos == -1 && last_pos == -1) {
  ------------------
  |  Branch (10943:9): [True: 0, False: 578]
  |  Branch (10943:28): [True: 0, False: 0]
  ------------------
10944|      0|      first_pos = 0;
10945|      0|      last_pos = static_cast<ssize_t>(content_length);
10946|      0|    }
10947|       |
10948|    578|    if (first_pos == -1) {
  ------------------
  |  Branch (10948:9): [True: 0, False: 578]
  ------------------
10949|      0|      first_pos = static_cast<ssize_t>(content_length) - last_pos;
10950|      0|      last_pos = static_cast<ssize_t>(content_length) - 1;
10951|      0|    }
10952|       |
10953|    578|    if (last_pos == -1 || last_pos >= static_cast<ssize_t>(content_length)) {
  ------------------
  |  Branch (10953:9): [True: 0, False: 578]
  |  Branch (10953:27): [True: 0, False: 578]
  ------------------
10954|      0|      last_pos = static_cast<ssize_t>(content_length) - 1;
10955|      0|    }
10956|       |
10957|       |    // Skip invalid ranges
10958|    578|    if (!(0 <= first_pos && first_pos <= last_pos &&
  ------------------
  |  Branch (10958:11): [True: 578, False: 0]
  |  Branch (10958:29): [True: 578, False: 0]
  ------------------
10959|    578|          last_pos < static_cast<ssize_t>(content_length))) {
  ------------------
  |  Branch (10959:11): [True: 578, False: 0]
  ------------------
10960|      0|      continue;
10961|      0|    }
10962|       |
10963|       |    // Coalesce with previous range if overlapping or adjacent (but not
10964|       |    // identical)
10965|    578|    if (!coalesced.empty()) {
  ------------------
  |  Branch (10965:9): [True: 445, False: 133]
  ------------------
10966|    445|      auto &prev = coalesced.back();
10967|       |      // Check if current range overlaps or is adjacent to previous range
10968|       |      // but don't coalesce identical ranges (allow duplicates)
10969|    445|      if (first_pos <= prev.second + 1 &&
  ------------------
  |  Branch (10969:11): [True: 291, False: 154]
  ------------------
10970|    291|          !(first_pos == prev.first && last_pos == prev.second)) {
  ------------------
  |  Branch (10970:13): [True: 83, False: 208]
  |  Branch (10970:40): [True: 65, False: 18]
  ------------------
10971|       |        // Extend the previous range
10972|    226|        prev.second = (std::max)(prev.second, last_pos);
10973|    226|        continue;
10974|    226|      }
10975|    445|    }
10976|       |
10977|       |    // Add new range
10978|    352|    coalesced.emplace_back(first_pos, last_pos);
10979|    352|  }
10980|       |
10981|    133|  ranges = std::move(coalesced);
10982|    133|}
_ZZN7httplib6detail15coalesce_rangesERNSt3__16vectorINS1_4pairIllEENS1_9allocatorIS4_EEEEmENKUlRKS4_SA_E_clESA_SA_:
10933|    884|            [](const Range &a, const Range &b) { return a.first < b.first; });
_ZN7httplib6detail13clear_contentERNS_8ResponseE:
13050|  1.75k|inline void clear_content(Response &res) {
13051|  1.75k|  res.body.clear();
13052|  1.75k|  clear_content_provider(res);
13053|  1.75k|}
_ZN7httplib6detail12read_contentINS_7RequestEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEb:
 9620|    356|                  ContentReceiverWithProgress receiver, bool decompress) {
 9621|    356|  bool exceed_payload_max_length = false;
 9622|    356|  return prepare_content_receiver(
 9623|    356|      x, status, std::move(receiver), decompress, payload_max_length,
 9624|    356|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 9625|    356|        auto ret = true;
 9626|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 9627|       |        // wrapper in prepare_content_receiver when the decompressed payload
 9628|       |        // size exceeds the limit.
 9629|       |
 9630|    356|        if (is_chunked_transfer_encoding(x.headers)) {
 9631|    356|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 9632|    356|          if (result == ReadContentResult::Success) {
 9633|    356|            ret = true;
 9634|    356|          } else if (result == ReadContentResult::PayloadTooLarge) {
 9635|    356|            exceed_payload_max_length = true;
 9636|    356|            ret = false;
 9637|    356|          } else {
 9638|    356|            ret = false;
 9639|    356|          }
 9640|    356|        } else if (!has_header(x.headers, "Content-Length")) {
 9641|    356|          auto result =
 9642|    356|              read_content_without_length(strm, payload_max_length, out);
 9643|    356|          if (result == ReadContentResult::Success) {
 9644|    356|            ret = true;
 9645|    356|          } else if (result == ReadContentResult::PayloadTooLarge) {
 9646|    356|            exceed_payload_max_length = true;
 9647|    356|            ret = false;
 9648|    356|          } else {
 9649|    356|            ret = false;
 9650|    356|          }
 9651|    356|        } else {
 9652|    356|          auto is_invalid_value = false;
 9653|    356|          auto len = get_header_value_u64(x.headers, "Content-Length",
 9654|    356|                                          (std::numeric_limits<size_t>::max)(),
 9655|    356|                                          0, is_invalid_value);
 9656|       |
 9657|    356|          if (is_invalid_value) {
 9658|    356|            ret = false;
 9659|    356|          } else if (len > 0) {
 9660|    356|            auto result = read_content_with_length(
 9661|    356|                strm, len, std::move(progress), out, payload_max_length);
 9662|    356|            ret = (result == ReadContentResult::Success);
 9663|    356|            if (result == ReadContentResult::PayloadTooLarge) {
 9664|    356|              exceed_payload_max_length = true;
 9665|    356|            }
 9666|    356|          }
 9667|    356|        }
 9668|       |
 9669|    356|        if (!ret) {
 9670|    356|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
 9671|    356|                                             : StatusCode::BadRequest_400;
 9672|    356|        }
 9673|    356|        return ret;
 9674|    356|      });
 9675|    356|}
_ZN7httplib6detail24prepare_content_receiverINS_7RequestEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_:
 9566|    356|                              bool &exceed_payload_max_length, U callback) {
 9567|    356|  if (decompress) {
  ------------------
  |  Branch (9567:7): [True: 0, False: 356]
  ------------------
 9568|      0|    auto encoding = get_combined_header_value(x.headers, "Content-Encoding");
 9569|      0|    std::unique_ptr<decompressor> decompressor;
 9570|       |
 9571|      0|    if (!encoding.empty()) {
  ------------------
  |  Branch (9571:9): [True: 0, False: 0]
  ------------------
 9572|       |      // A coding we know about but were not built with is an error. An
 9573|       |      // unrecognized coding (including "identity") is left alone and the
 9574|       |      // payload is passed through as-is, since some servers misuse the header,
 9575|       |      // e.g. by sending a character set such as "Content-Encoding: UTF-8".
 9576|      0|      decompressor = detail::create_decompressor(encoding);
 9577|      0|      if (!decompressor && detail::is_known_content_encoding(encoding)) {
  ------------------
  |  Branch (9577:11): [True: 0, False: 0]
  |  Branch (9577:28): [True: 0, False: 0]
  ------------------
 9578|      0|        status = StatusCode::UnsupportedMediaType_415;
 9579|      0|        return false;
 9580|      0|      }
 9581|      0|    }
 9582|       |
 9583|      0|    if (decompressor) {
  ------------------
  |  Branch (9583:9): [True: 0, False: 0]
  ------------------
 9584|      0|      if (decompressor->is_valid()) {
  ------------------
  |  Branch (9584:11): [True: 0, False: 0]
  ------------------
 9585|      0|        size_t decompressed_size = 0;
 9586|      0|        ContentReceiverWithProgress out = [&](const char *buf, size_t n,
 9587|      0|                                              size_t off, size_t len) {
 9588|      0|          return decompressor->decompress(
 9589|      0|              buf, n, [&](const char *buf2, size_t n2) {
 9590|       |                // Guard against zip-bomb: check
 9591|       |                // decompressed size against limit.
 9592|      0|                if (payload_max_length > 0 &&
 9593|      0|                    (decompressed_size >= payload_max_length ||
 9594|      0|                     n2 > payload_max_length - decompressed_size)) {
 9595|      0|                  exceed_payload_max_length = true;
 9596|      0|                  return false;
 9597|      0|                }
 9598|      0|                decompressed_size += n2;
 9599|      0|                return receiver(buf2, n2, off, len);
 9600|      0|              });
 9601|      0|        };
 9602|      0|        return callback(std::move(out));
 9603|      0|      } else {
 9604|      0|        status = StatusCode::InternalServerError_500;
 9605|      0|        return false;
 9606|      0|      }
 9607|      0|    }
 9608|      0|  }
 9609|       |
 9610|    356|  ContentReceiverWithProgress out = [&](const char *buf, size_t n, size_t off,
 9611|    356|                                        size_t len) {
 9612|    356|    return receiver(buf, n, off, len);
 9613|    356|  };
 9614|    356|  return callback(std::move(out));
 9615|    356|}
_ZZN7httplib6detail12read_contentINS_7RequestEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEbENKUlRKSF_E_clESH_:
 9624|    356|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 9625|    356|        auto ret = true;
 9626|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 9627|       |        // wrapper in prepare_content_receiver when the decompressed payload
 9628|       |        // size exceeds the limit.
 9629|       |
 9630|    356|        if (is_chunked_transfer_encoding(x.headers)) {
  ------------------
  |  Branch (9630:13): [True: 0, False: 356]
  ------------------
 9631|      0|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 9632|      0|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (9632:15): [True: 0, False: 0]
  ------------------
 9633|      0|            ret = true;
 9634|      0|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9634:22): [True: 0, False: 0]
  ------------------
 9635|      0|            exceed_payload_max_length = true;
 9636|      0|            ret = false;
 9637|      0|          } else {
 9638|      0|            ret = false;
 9639|      0|          }
 9640|    356|        } else if (!has_header(x.headers, "Content-Length")) {
  ------------------
  |  Branch (9640:20): [True: 0, False: 356]
  ------------------
 9641|      0|          auto result =
 9642|      0|              read_content_without_length(strm, payload_max_length, out);
 9643|      0|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (9643:15): [True: 0, False: 0]
  ------------------
 9644|      0|            ret = true;
 9645|      0|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9645:22): [True: 0, False: 0]
  ------------------
 9646|      0|            exceed_payload_max_length = true;
 9647|      0|            ret = false;
 9648|      0|          } else {
 9649|      0|            ret = false;
 9650|      0|          }
 9651|    356|        } else {
 9652|    356|          auto is_invalid_value = false;
 9653|    356|          auto len = get_header_value_u64(x.headers, "Content-Length",
 9654|    356|                                          (std::numeric_limits<size_t>::max)(),
 9655|    356|                                          0, is_invalid_value);
 9656|       |
 9657|    356|          if (is_invalid_value) {
  ------------------
  |  Branch (9657:15): [True: 0, False: 356]
  ------------------
 9658|      0|            ret = false;
 9659|    356|          } else if (len > 0) {
  ------------------
  |  Branch (9659:22): [True: 356, False: 0]
  ------------------
 9660|    356|            auto result = read_content_with_length(
 9661|    356|                strm, len, std::move(progress), out, payload_max_length);
 9662|    356|            ret = (result == ReadContentResult::Success);
 9663|    356|            if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9663:17): [True: 9, False: 347]
  ------------------
 9664|      9|              exceed_payload_max_length = true;
 9665|      9|            }
 9666|    356|          }
 9667|    356|        }
 9668|       |
 9669|    356|        if (!ret) {
  ------------------
  |  Branch (9669:13): [True: 348, False: 8]
  ------------------
 9670|    348|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
  ------------------
  |  Branch (9670:20): [True: 9, False: 339]
  ------------------
 9671|    348|                                             : StatusCode::BadRequest_400;
 9672|    348|        }
 9673|    356|        return ret;
 9674|    356|      });
_ZN7httplib6detail24read_content_with_lengthERNS_6StreamEmNSt3__18functionIFbmmEEENS4_IFbPKcmmmEEEm:
 9412|    356|    size_t payload_max_length = (std::numeric_limits<size_t>::max)()) {
 9413|    356|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 9414|       |
 9415|    356|  detail::BodyReader br;
 9416|    356|  br.stream = &strm;
 9417|    356|  br.has_content_length = true;
 9418|    356|  br.content_length = len;
 9419|    356|  br.payload_max_length = payload_max_length;
 9420|    356|  br.chunked = false;
 9421|    356|  br.bytes_read = 0;
 9422|    356|  br.last_error = Error::Success;
 9423|       |
 9424|    356|  size_t r = 0;
 9425|    752|  while (r < len) {
  ------------------
  |  Branch (9425:10): [True: 744, False: 8]
  ------------------
 9426|    744|    auto read_len = static_cast<size_t>(len - r);
 9427|    744|    auto to_read = (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ);
  ------------------
  |  |  199|    744|#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
  ------------------
 9428|    744|    auto n = detail::read_body_content(&strm, br, buf, to_read);
 9429|    744|    if (n <= 0) {
  ------------------
  |  Branch (9429:9): [True: 348, False: 396]
  ------------------
 9430|       |      // Check if it was a payload size error
 9431|    348|      if (br.last_error == Error::ExceedMaxPayloadSize) {
  ------------------
  |  Branch (9431:11): [True: 9, False: 339]
  ------------------
 9432|      9|        return ReadContentResult::PayloadTooLarge;
 9433|      9|      }
 9434|    339|      return ReadContentResult::Error;
 9435|    348|    }
 9436|       |
 9437|    396|    if (!out(buf, static_cast<size_t>(n), r, len)) {
  ------------------
  |  Branch (9437:9): [True: 0, False: 396]
  ------------------
 9438|      0|      return ReadContentResult::Error;
 9439|      0|    }
 9440|    396|    r += static_cast<size_t>(n);
 9441|       |
 9442|    396|    if (progress) {
  ------------------
  |  Branch (9442:9): [True: 0, False: 396]
  ------------------
 9443|      0|      if (!progress(r, len)) { return ReadContentResult::Error; }
  ------------------
  |  Branch (9443:11): [True: 0, False: 0]
  ------------------
 9444|      0|    }
 9445|    396|  }
 9446|       |
 9447|      8|  return ReadContentResult::Success;
 9448|    356|}
_ZN7httplib6detail17read_body_contentEPNS_6StreamERNS0_10BodyReaderEPcm:
 2797|    744|                                 size_t len) {
 2798|    744|  (void)stream;
 2799|    744|  return br.read(buf, len);
 2800|    744|}
_ZN7httplib6detail10BodyReader4readEPcm:
13271|    744|inline ssize_t detail::BodyReader::read(char *buf, size_t len) {
13272|    744|  if (!stream) {
  ------------------
  |  Branch (13272:7): [True: 0, False: 744]
  ------------------
13273|      0|    last_error = Error::Connection;
13274|      0|    return -1;
13275|      0|  }
13276|    744|  if (eof) { return 0; }
  ------------------
  |  Branch (13276:7): [True: 0, False: 744]
  ------------------
13277|       |
13278|    744|  if (!chunked) {
  ------------------
  |  Branch (13278:7): [True: 744, False: 0]
  ------------------
13279|       |    // Content-Length based reading
13280|    744|    if (has_content_length && bytes_read >= content_length) {
  ------------------
  |  Branch (13280:9): [True: 744, False: 0]
  |  Branch (13280:31): [True: 0, False: 744]
  ------------------
13281|      0|      eof = true;
13282|      0|      return 0;
13283|      0|    }
13284|       |
13285|    744|    auto to_read = len;
13286|    744|    if (has_content_length) {
  ------------------
  |  Branch (13286:9): [True: 744, False: 0]
  ------------------
13287|    744|      auto remaining = content_length - bytes_read;
13288|    744|      to_read = (std::min)(len, remaining);
13289|    744|    }
13290|    744|    auto n = stream->read(buf, to_read);
13291|       |
13292|       |    // Without Content-Length the body ends when the connection closes
13293|       |    // (RFC 9112 §6.3); with one, an EOF here came too early
13294|    744|    if (n < 0 || (n == 0 && has_content_length)) {
  ------------------
  |  Branch (13294:9): [True: 0, False: 744]
  |  Branch (13294:19): [True: 339, False: 405]
  |  Branch (13294:29): [True: 339, False: 0]
  ------------------
13295|    339|      last_error = stream->get_error();
13296|    339|      if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (13296:11): [True: 339, False: 0]
  ------------------
13297|    339|    }
13298|    744|    if (n <= 0) {
  ------------------
  |  Branch (13298:9): [True: 339, False: 405]
  ------------------
13299|    339|      eof = true;
13300|    339|      return n;
13301|    339|    }
13302|       |
13303|    405|    bytes_read += static_cast<size_t>(n);
13304|    405|    if (has_content_length && bytes_read >= content_length) { eof = true; }
  ------------------
  |  Branch (13304:9): [True: 405, False: 0]
  |  Branch (13304:31): [True: 8, False: 397]
  ------------------
13305|    405|    if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (13305:9): [True: 405, False: 0]
  |  Branch (13305:35): [True: 9, False: 396]
  ------------------
13306|      9|      last_error = Error::ExceedMaxPayloadSize;
13307|      9|      eof = true;
13308|      9|      return -1;
13309|      9|    }
13310|    396|    return n;
13311|    405|  }
13312|       |
13313|       |  // Chunked transfer encoding: delegate to shared decoder instance.
13314|      0|  if (!chunked_decoder) { chunked_decoder.reset(new ChunkedDecoder(*stream)); }
  ------------------
  |  Branch (13314:7): [True: 0, False: 0]
  ------------------
13315|       |
13316|      0|  size_t chunk_offset = 0;
13317|      0|  size_t chunk_total = 0;
13318|      0|  auto n = chunked_decoder->read_payload(buf, len, chunk_offset, chunk_total);
13319|      0|  if (n < 0) {
  ------------------
  |  Branch (13319:7): [True: 0, False: 0]
  ------------------
13320|      0|    last_error = stream->get_error();
13321|      0|    if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (13321:9): [True: 0, False: 0]
  ------------------
13322|      0|    eof = true;
13323|      0|    return n;
13324|      0|  }
13325|       |
13326|      0|  if (n == 0) {
  ------------------
  |  Branch (13326:7): [True: 0, False: 0]
  ------------------
13327|       |    // Final chunk observed. Leave trailer parsing to the caller (StreamHandle).
13328|      0|    eof = true;
13329|      0|    return 0;
13330|      0|  }
13331|       |
13332|      0|  bytes_read += static_cast<size_t>(n);
13333|      0|  if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (13333:7): [True: 0, False: 0]
  |  Branch (13333:33): [True: 0, False: 0]
  ------------------
13334|      0|    last_error = Error::ExceedMaxPayloadSize;
13335|      0|    eof = true;
13336|      0|    return -1;
13337|      0|  }
13338|      0|  return n;
13339|      0|}
_ZZN7httplib6detail24prepare_content_receiverINS_7RequestEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_ENKUlSE_mmmE0_clESE_mmm:
 9611|    396|                                        size_t len) {
 9612|    396|    return receiver(buf, n, off, len);
 9613|    396|  };
_ZZN7httplib6Server15process_requestERNS_6StreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEiSB_ibRbRKNS3_8functionIFvRNS_7RequestEEEEPbENKUlPKcmmmE_clESM_mmm:
16582|    396|            nullptr, [](const char *, size_t, size_t, size_t) { return true; },
_ZN7httplib6detail10scope_exitD2Ev:
  771|  5.71k|  ~scope_exit() {
  772|  5.71k|    if (execute_on_destruction) { this->exit_function(); }
  ------------------
  |  Branch (772:9): [True: 5.71k, False: 0]
  ------------------
  773|  5.71k|  }
_ZN7httplib8ResponseD2Ev:
 1974|  5.71k|  ~Response() {
 1975|  5.71k|    if (content_provider_resource_releaser_) {
  ------------------
  |  Branch (1975:9): [True: 0, False: 5.71k]
  ------------------
 1976|      0|      content_provider_resource_releaser_(content_provider_success_);
 1977|      0|    }
 1978|  5.71k|  }
_ZN7httplib6detail12BufferStreamD2Ev:
 4111|  5.71k|  ~BufferStream() override = default;
_ZNK7httplib6detail12BufferStream13wait_writableEv:
13695|  2.93k|inline bool BufferStream::wait_writable() const { return true; }
_ZNK7httplib6Stream13is_peer_aliveEv:
 2052|  1.46k|  virtual bool is_peer_alive() const { return wait_writable(); }
_ZN7httplib6detail12BufferStream5writeEPKcm:
13707|  33.2k|inline ssize_t BufferStream::write(const char *ptr, size_t size) {
13708|  33.2k|  buffer.append(ptr, size);
13709|  33.2k|  return static_cast<ssize_t>(size);
13710|  33.2k|}
_ZN7httplib6Stream15set_max_timeoutEl:
 2069|  10.1k|  virtual void set_max_timeout(time_t msec) { (void)msec; }

_ZN14FuzzableServer13MarkAsRunningEv:
   73|      2|  void MarkAsRunning() { svr_sock_ = 0; }
_ZN12FuzzedStreamC2EPKhm:
   10|  5.72k|      : data_(data), size_(size), read_pos_(0) {}
_ZN12FuzzedStream4readEPcm:
   12|  13.2k|  ssize_t read(char *ptr, size_t size) override {
   13|  13.2k|    if (size + read_pos_ > size_) { size = size_ - read_pos_; }
  ------------------
  |  Branch (13:9): [True: 1.73k, False: 11.4k]
  ------------------
   14|  13.2k|    memcpy(ptr, data_ + read_pos_, size);
   15|  13.2k|    read_pos_ += size;
   16|       |    // Like SocketStream, pull in more than was asked for, which the line
   17|       |    // reader then takes through buffered_data(), so both of its paths run.
   18|  13.2k|    buffered_end_ =
   19|  13.2k|        (std::max)(buffered_end_, (std::min)(size_, read_pos_ + 4096));
   20|  13.2k|    return static_cast<ssize_t>(size);
   21|  13.2k|  }
_ZN12FuzzedStream5writeEPKcm:
   30|  5.71k|  ssize_t write(const char *ptr, size_t size) override {
   31|  5.71k|    response_.append(ptr, size);
   32|  5.71k|    return static_cast<int>(size);
   33|  5.71k|  }
_ZNK12FuzzedStream6socketEv:
   55|  3.24k|  socket_t socket() const override { return 0; }
_ZNK12FuzzedStream13buffered_dataERm:
   23|  44.2k|  const char *buffered_data(size_t &size) const override {
   24|  44.2k|    size = buffered_end_ > read_pos_ ? buffered_end_ - read_pos_ : 0;
  ------------------
  |  Branch (24:12): [True: 31.7k, False: 12.4k]
  ------------------
   25|  44.2k|    return size ? reinterpret_cast<const char *>(data_ + read_pos_) : nullptr;
  ------------------
  |  Branch (25:12): [True: 31.7k, False: 12.4k]
  ------------------
   26|  44.2k|  }
_ZN12FuzzedStream16consume_bufferedEm:
   28|  31.7k|  void consume_buffered(size_t size) override { read_pos_ += size; }
_ZN14FuzzableServer20ProcessFuzzedRequestER12FuzzedStream:
   75|  5.72k|  void ProcessFuzzedRequest(FuzzedStream &stream) {
   76|  5.72k|    bool connection_close = false;
   77|  5.72k|    process_request(stream,
   78|  5.72k|                    /*remote_addr=*/"",
   79|  5.72k|                    /*remote_port =*/0,
   80|  5.72k|                    /*local_addr=*/"",
   81|  5.72k|                    /*local_port =*/0,
   82|  5.72k|                    /*last_connection=*/false, connection_close, nullptr);
   83|  5.72k|  }
_ZNK12FuzzedStream8responseEv:
   59|  5.72k|  const std::string &response() const { return response_; }

LLVMFuzzerInitialize:
   80|      2|extern "C" int LLVMFuzzerInitialize(int * /*argc*/, char *** /*argv*/) {
   81|      2|  std::random_device rd;
   82|      2|  char token[33];
   83|      2|  snprintf(token, sizeof(token), "%08x%08x%08x%08x", rd(), rd(), rd(), rd());
   84|      2|  g_token = token;
   85|       |
   86|      2|  auto tmpdir = getenv("TMPDIR");
   87|      2|  auto tmpl = std::string(tmpdir && *tmpdir ? tmpdir : "/tmp") +
  ------------------
  |  Branch (87:27): [True: 0, False: 2]
  |  Branch (87:37): [True: 0, False: 0]
  ------------------
   88|      2|              "/httplib-mount-XXXXXX";
   89|      2|  check(mkdtemp(&tmpl[0]) != nullptr, tmpl.c_str());
   90|      2|  g_root = tmpl;
   91|      2|  atexit(remove_fixture);
   92|       |
   93|      2|  auto mnt = g_root + "/mnt";
   94|      2|  make_dir(mnt);
   95|      2|  make_dir(mnt + "/sub");
   96|      2|  make_dir(g_root + "/mnt_secret");
   97|      2|  make_file(mnt + "/index.html", "<html>index</html>");
   98|      2|  make_file(mnt + "/a.txt", "abcdef");
   99|      2|  make_file(mnt + "/data.bin", std::string("\x01\x02\x03\x04\x05\x06", 6));
  100|      2|  make_file(mnt + "/sub/index.html", "<html>sub</html>");
  101|      2|  make_file(g_root + "/outside.txt", g_token);
  102|      2|  make_file(g_root + "/mnt_secret/secret.txt", g_token);
  103|      2|  make_link("a.txt", mnt + "/link-in.txt");
  104|      2|  make_link("../outside.txt", mnt + "/link-out.txt");
  105|      2|  make_link("../mnt_secret/secret.txt", mnt + "/link-sibling.txt");
  106|       |
  107|      2|  g_server.MarkAsRunning();
  108|      2|  check(g_server.set_mount_point("/mnt", mnt), "set_mount_point");
  109|      2|  check_served("/mnt/a.txt");
  110|      2|  check_served("/mnt/link-in.txt");
  111|      2|  return 0;
  112|      2|}
LLVMFuzzerTestOneInput:
  114|  5.71k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  115|  5.71k|  if (serve(data, size).find(g_token) != std::string::npos) { abort(); }
  ------------------
  |  Branch (115:7): [True: 0, False: 5.71k]
  ------------------
  116|  5.71k|  return 0;
  117|  5.71k|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_15checkEbPKc:
   29|     44|void check(bool ok, const char *what) {
   30|     44|  if (!ok) {
  ------------------
  |  Branch (30:7): [True: 0, False: 44]
  ------------------
   31|       |    fprintf(stderr, "fixture setup failed: %s\n", what);
   32|      0|    abort();
   33|      0|  }
   34|     44|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_114remove_fixtureEv:
   71|      2|void remove_fixture() {
   72|     26|  for (auto it = g_paths.rbegin(); it != g_paths.rend(); ++it) {
  ------------------
  |  Branch (72:36): [True: 24, False: 2]
  ------------------
   73|     24|    if (unlink(it->c_str()) != 0) { rmdir(it->c_str()); }
  ------------------
  |  Branch (73:9): [True: 6, False: 18]
  ------------------
   74|     24|  }
   75|      2|  rmdir(g_root.c_str());
   76|      2|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_18make_dirERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE:
   36|      6|void make_dir(const std::string &path) {
   37|      6|  check(mkdir(path.c_str(), 0755) == 0, path.c_str());
   38|      6|  g_paths.push_back(path);
   39|      6|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_19make_fileERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_:
   41|     12|void make_file(const std::string &path, const std::string &content) {
   42|     12|  {
   43|     12|    std::ofstream out(path, std::ios::binary);
   44|     12|    out << content;
   45|     12|    check(out.good(), path.c_str());
   46|     12|  }
   47|       |  // Fixed, so that conditional requests behave the same in every run
   48|     12|  utimbuf times = {1700000000, 1700000000};
   49|     12|  check(utime(path.c_str(), &times) == 0, path.c_str());
   50|     12|  g_paths.push_back(path);
   51|     12|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_19make_linkERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_:
   53|      6|void make_link(const std::string &target, const std::string &path) {
   54|      6|  check(symlink(target.c_str(), path.c_str()) == 0, path.c_str());
   55|      6|  g_paths.push_back(path);
   56|      6|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_112check_servedEPKc:
   64|      4|void check_served(const char *path) {
   65|      4|  auto req = std::string("GET ") + path + " HTTP/1.1\r\nHost: x\r\n\r\n";
   66|      4|  auto res = serve(reinterpret_cast<const uint8_t *>(req.data()), req.size());
   67|       |  // Without this, a fuzzer that serves nothing would pass its check forever
   68|      4|  check(res.find("abcdef") != std::string::npos, path);
   69|      4|}
server_mount_fuzzer.cc:_ZN12_GLOBAL__N_15serveEPKhm:
   58|  5.72k|std::string serve(const uint8_t *data, size_t size) {
   59|  5.72k|  FuzzedStream stream{data, size};
   60|  5.72k|  g_server.ProcessFuzzedRequest(stream);
   61|  5.72k|  return stream.response();
   62|  5.72k|}

