_ZN7httplib6detail17gzip_decompressorD2Ev:
 8097|    148|inline gzip_decompressor::~gzip_decompressor() { inflateEnd(&strm_); }
_ZN7httplib10ClientImplD2Ev:
15469|  3.13k|inline ClientImpl::~ClientImpl() {
15470|       |  // Wait until all the requests in flight are handled.
15471|  3.13k|  size_t retry_count = 10;
15472|  3.13k|  while (retry_count-- > 0) {
  ------------------
  |  Branch (15472:10): [True: 3.13k, False: 0]
  ------------------
15473|  3.13k|    {
15474|  3.13k|      std::lock_guard<std::mutex> guard(socket_mutex_);
15475|  3.13k|      if (socket_requests_in_flight_ == 0) { break; }
  ------------------
  |  Branch (15475:11): [True: 3.13k, False: 0]
  ------------------
15476|  3.13k|    }
15477|      0|    std::this_thread::sleep_for(std::chrono::milliseconds{1});
15478|      0|  }
15479|       |
15480|  3.13k|  std::lock_guard<std::mutex> guard(socket_mutex_);
15481|  3.13k|  shutdown_socket(socket_);
15482|  3.13k|  close_socket(socket_);
15483|  3.13k|}
_ZN7httplib6detail12decompressorD2Ev:
 3882|    148|  virtual ~decompressor() = default;
_ZN7httplib6StreamD2Ev:
 1999|  6.27k|  virtual ~Stream() = default;
_ZNK7httplib10ClientImpl15shutdown_socketERNS0_6SocketE:
15552|  3.13k|inline void ClientImpl::shutdown_socket(Socket &socket) const {
15553|  3.13k|  if (socket.sock == INVALID_SOCKET) { return; }
  ------------------
  |  |  375|  3.13k|#define INVALID_SOCKET (-1)
  ------------------
  |  Branch (15553:7): [True: 3.13k, False: 0]
  ------------------
15554|      0|  detail::shutdown_socket(socket.sock);
15555|      0|}
_ZN7httplib10ClientImpl12close_socketERNS0_6SocketE:
15557|  3.13k|inline void ClientImpl::close_socket(Socket &socket) {
15558|       |  // If there are requests in flight in another thread, usually closing
15559|       |  // the socket will be fine and they will simply receive an error when
15560|       |  // using the closed socket, but it is still a bug since rarely the OS
15561|       |  // may reassign the socket id to be used for a new socket, and then
15562|       |  // suddenly they will be operating on a live socket that is different
15563|       |  // than the one they intended!
15564|  3.13k|  assert(socket_requests_in_flight_ == 0 ||
  ------------------
  |  Branch (15564:3): [True: 3.13k, False: 0]
  |  Branch (15564:3): [True: 0, False: 0]
  |  Branch (15564:3): [True: 3.13k, False: 0]
  ------------------
15565|  3.13k|         socket_requests_are_from_thread_ == std::this_thread::get_id());
15566|       |
15567|       |  // It is also a bug if this happens while SSL is still active
15568|       |#ifdef CPPHTTPLIB_SSL_ENABLED
15569|       |  assert(socket.ssl == nullptr);
15570|       |#endif
15571|       |
15572|  3.13k|  if (socket.sock == INVALID_SOCKET) { return; }
  ------------------
  |  |  375|  3.13k|#define INVALID_SOCKET (-1)
  ------------------
  |  Branch (15572:7): [True: 3.13k, False: 0]
  ------------------
15573|      0|  detail::close_socket(socket.sock);
15574|      0|  socket.sock = INVALID_SOCKET;
  ------------------
  |  |  375|      0|#define INVALID_SOCKET (-1)
  ------------------
15575|      0|}
_ZN7httplib10ClientImplC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi:
15461|  3.13k|    : ClientImpl(host, port, std::string(), std::string()) {}
_ZN7httplib10ClientImplC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEiS9_S9_:
15466|  3.13k|    : host_(detail::escape_abstract_namespace_unix_domain(host)), port_(port),
15467|  3.13k|      client_cert_path_(client_cert_path), client_key_path_(client_key_path) {}
_ZN7httplib6detail37escape_abstract_namespace_unix_domainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 7007|  3.13k|inline std::string escape_abstract_namespace_unix_domain(const std::string &s) {
 7008|  3.13k|  if (s.size() > 1 && s[0] == '\0') {
  ------------------
  |  Branch (7008:7): [True: 3.13k, False: 0]
  |  Branch (7008:23): [True: 0, False: 3.13k]
  ------------------
 7009|      0|    auto ret = s;
 7010|      0|    ret[0] = '@';
 7011|      0|    return ret;
 7012|      0|  }
 7013|  3.13k|  return s;
 7014|  3.13k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEC2Ev:
 1251|  18.6k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail13write_headersERNS_6StreamERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 8908|  3.13k|inline ssize_t write_headers(Stream &strm, const Headers &headers) {
 8909|  3.13k|  ssize_t write_len = 0;
 8910|  14.6k|  for (const auto &x : headers) {
  ------------------
  |  Branch (8910:22): [True: 14.6k, False: 3.13k]
  ------------------
 8911|       |    // Skip fields with invalid names or values to prevent response splitting
 8912|       |    // via CR/LF injection, matching set_header(). The client validates request
 8913|       |    // headers up front in check_and_write_headers, but the server passes
 8914|       |    // res.headers straight to this writer, and res.headers is a public field
 8915|       |    // an application can populate directly with request-derived values.
 8916|  14.6k|    if (!fields::is_field_valid(x.first, x.second)) { continue; }
  ------------------
  |  Branch (8916:9): [True: 0, False: 14.6k]
  ------------------
 8917|       |
 8918|  14.6k|    std::string s;
 8919|  14.6k|    s = x.first;
 8920|  14.6k|    s += ": ";
 8921|  14.6k|    s += x.second;
 8922|  14.6k|    s += "\r\n";
 8923|       |
 8924|  14.6k|    auto len = strm.write(s.data(), s.size());
 8925|  14.6k|    if (len < 0) { return len; }
  ------------------
  |  Branch (8925:9): [True: 0, False: 14.6k]
  ------------------
 8926|  14.6k|    write_len += len;
 8927|  14.6k|  }
 8928|  3.13k|  auto len = strm.write("\r\n");
 8929|  3.13k|  if (len < 0) { return len; }
  ------------------
  |  Branch (8929:7): [True: 0, False: 3.13k]
  ------------------
 8930|  3.13k|  write_len += len;
 8931|  3.13k|  return write_len;
 8932|  3.13k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1260|  3.13k|  const_iterator begin() const { return make_citer(0, npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10make_citerEmm:
 1393|  82.1k|  const_iterator make_citer(size_type idx, size_type key_idx) const {
 1394|  82.1k|    return const_iterator(entries_.data(), idx, entries_.size(), key_idx);
 1395|  82.1k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEC2EPSF_mmm:
 1235|  82.1k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4nposEv:
 1155|   249k|  static size_type npos() { return static_cast<size_type>(-1); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1261|  73.5k|  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:
 1226|  57.5k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1227|  57.5k|      return idx_ != rhs.idx_;
 1228|  57.5k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEdeEv:
 1183|  14.6k|    reference operator*() const { return data_[idx_]; }
_ZN7httplib6detail6fields14is_field_validERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
10589|  37.6k|inline bool is_field_valid(const std::string &name, const std::string &value) {
10590|  37.6k|  return is_field_name(name) && is_field_value(value);
  ------------------
  |  Branch (10590:10): [True: 37.6k, False: 0]
  |  Branch (10590:33): [True: 37.6k, False: 0]
  ------------------
10591|  37.6k|}
_ZN7httplib6detail6fields13is_field_nameERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
10554|  62.7k|inline bool is_field_name(const std::string &s) { return is_token(s); }
_ZN7httplib6detail6fields8is_tokenERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
10546|  65.8k|inline bool is_token(const std::string &s) {
10547|  65.8k|  if (s.empty()) { return false; }
  ------------------
  |  Branch (10547:7): [True: 64, False: 65.7k]
  ------------------
10548|   607k|  for (auto c : s) {
  ------------------
  |  Branch (10548:15): [True: 607k, False: 65.6k]
  ------------------
10549|   607k|    if (!is_token_char(c)) { return false; }
  ------------------
  |  Branch (10549:9): [True: 154, False: 607k]
  ------------------
10550|   607k|  }
10551|  65.6k|  return true;
10552|  65.7k|}
_ZN7httplib6detail6fields13is_token_charEc:
10540|   607k|inline bool is_token_char(char c) {
10541|   607k|  return is_ascii_alnum(c) || c == '!' || c == '#' || c == '$' || c == '%' ||
  ------------------
  |  Branch (10541:10): [True: 557k, False: 49.7k]
  |  Branch (10541:31): [True: 630, False: 49.0k]
  |  Branch (10541:43): [True: 1.47k, False: 47.6k]
  |  Branch (10541:55): [True: 784, False: 46.8k]
  |  Branch (10541:67): [True: 1.05k, False: 45.7k]
  ------------------
10542|  45.7k|         c == '&' || c == '\'' || c == '*' || c == '+' || c == '-' ||
  ------------------
  |  Branch (10542:10): [True: 1.68k, False: 44.1k]
  |  Branch (10542:22): [True: 512, False: 43.5k]
  |  Branch (10542:35): [True: 1.42k, False: 42.1k]
  |  Branch (10542:47): [True: 731, False: 41.4k]
  |  Branch (10542:59): [True: 33.2k, False: 8.19k]
  ------------------
10543|  8.19k|         c == '.' || c == '^' || c == '_' || c == '`' || c == '|' || c == '~';
  ------------------
  |  Branch (10543:10): [True: 321, False: 7.86k]
  |  Branch (10543:22): [True: 2.23k, False: 5.63k]
  |  Branch (10543:34): [True: 2.69k, False: 2.94k]
  |  Branch (10543:46): [True: 796, False: 2.15k]
  |  Branch (10543:58): [True: 460, False: 1.69k]
  |  Branch (10543:70): [True: 1.53k, False: 154]
  ------------------
10544|   607k|}
_ZN7httplib6detail14is_ascii_alnumEc:
  648|   607k|inline bool is_ascii_alnum(char c) {
  649|   607k|  return is_ascii_digit(c) || is_ascii_alpha(c);
  ------------------
  |  Branch (649:10): [True: 20.0k, False: 587k]
  |  Branch (649:31): [True: 537k, False: 49.7k]
  ------------------
  650|   607k|}
_ZN7httplib6detail14is_ascii_digitEc:
  642|   666k|inline bool is_ascii_digit(char c) { return '0' <= c && c <= '9'; }
  ------------------
  |  Branch (642:45): [True: 624k, False: 42.3k]
  |  Branch (642:57): [True: 75.0k, False: 549k]
  ------------------
_ZN7httplib6detail14is_ascii_alphaEc:
  644|   587k|inline bool is_ascii_alpha(char c) {
  645|   587k|  return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
  ------------------
  |  Branch (645:11): [True: 430k, False: 156k]
  |  Branch (645:23): [True: 428k, False: 2.00k]
  |  Branch (645:37): [True: 116k, False: 41.9k]
  |  Branch (645:49): [True: 109k, False: 7.72k]
  ------------------
  646|   587k|}
_ZN7httplib6detail6fields14is_field_valueERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
10587|  62.2k|inline bool is_field_value(const std::string &s) { return is_field_content(s); }
_ZN7httplib6detail6fields16is_field_contentERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
10562|  62.2k|inline bool is_field_content(const std::string &s) {
10563|  62.2k|  if (s.empty()) { return true; }
  ------------------
  |  Branch (10563:7): [True: 15.3k, False: 46.9k]
  ------------------
10564|       |
10565|  46.9k|  if (s.size() == 1) {
  ------------------
  |  Branch (10565:7): [True: 7.42k, False: 39.4k]
  ------------------
10566|  7.42k|    return is_field_vchar(s[0]);
10567|  39.4k|  } else if (s.size() == 2) {
  ------------------
  |  Branch (10567:14): [True: 1.40k, False: 38.0k]
  ------------------
10568|  1.40k|    return is_field_vchar(s[0]) && is_field_vchar(s[1]);
  ------------------
  |  Branch (10568:12): [True: 1.40k, False: 4]
  |  Branch (10568:36): [True: 1.40k, False: 4]
  ------------------
10569|  38.0k|  } else {
10570|  38.0k|    size_t i = 0;
10571|       |
10572|  38.0k|    if (!is_field_vchar(s[i])) { return false; }
  ------------------
  |  Branch (10572:9): [True: 9, False: 38.0k]
  ------------------
10573|  38.0k|    i++;
10574|       |
10575|  2.78M|    while (i < s.size() - 1) {
  ------------------
  |  Branch (10575:12): [True: 2.75M, False: 38.0k]
  ------------------
10576|  2.75M|      auto c = s[i++];
10577|  2.75M|      if (c == ' ' || c == '\t' || is_field_vchar(c)) {
  ------------------
  |  Branch (10577:11): [True: 24.9k, False: 2.72M]
  |  Branch (10577:23): [True: 3.61k, False: 2.72M]
  |  Branch (10577:36): [True: 2.72M, False: 49]
  ------------------
10578|  2.75M|      } else {
10579|     49|        return false;
10580|     49|      }
10581|  2.75M|    }
10582|       |
10583|  38.0k|    return is_field_vchar(s[i]);
10584|  38.0k|  }
10585|  46.9k|}
_ZN7httplib6detail6fields14is_field_vcharEc:
10560|  2.81M|inline bool is_field_vchar(char c) { return is_vchar(c) || is_obs_text(c); }
  ------------------
  |  Branch (10560:45): [True: 1.65M, False: 1.15M]
  |  Branch (10560:60): [True: 1.15M, False: 105]
  ------------------
_ZN7httplib6detail6fields8is_vcharEc:
10556|  2.81M|inline bool is_vchar(char c) { return c >= 33 && c <= 126; }
  ------------------
  |  Branch (10556:39): [True: 1.65M, False: 1.15M]
  |  Branch (10556:50): [True: 1.65M, False: 5]
  ------------------
_ZN7httplib6detail6fields11is_obs_textEc:
10558|  1.15M|inline bool is_obs_text(char c) { return 128 <= static_cast<unsigned char>(c); }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEppEv:
 1186|  17.2k|    iterator_t &operator++() {
 1187|       |      // Saturating, so that advancing past the last entry of a key stays at
 1188|       |      // end() instead of running off the container.
 1189|  17.2k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1189:11): [True: 0, False: 17.2k]
  ------------------
 1190|  17.2k|      ++idx_;
 1191|  17.2k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1191:11): [True: 2.56k, False: 14.6k]
  ------------------
 1192|  3.43k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1192:16): [True: 2.22k, False: 1.20k]
  |  Branch (1192:32): [True: 867, False: 1.35k]
  ------------------
 1193|    867|          ++idx_;
 1194|    867|        }
 1195|  2.56k|      }
 1196|  17.2k|      return *this;
 1197|  17.2k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEE7matchesEm:
 1237|  2.22k|    bool matches(size_type i) const {
 1238|  2.22k|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1239|  2.22k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10keys_equalERKS8_SD_:
 1157|  88.2k|  static bool keys_equal(const std::string &a, const std::string &b) {
 1158|  88.2k|    return KeyEqual()(a, b);
 1159|  88.2k|  }
_ZNK7httplib6detail11case_ignore8equal_toclERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_:
  703|  88.2k|  bool operator()(const std::string &a, const std::string &b) const {
  704|  88.2k|    return equal(a, b);
  705|  88.2k|  }
_ZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
  686|  88.2k|inline bool equal(const std::string &a, const std::string &b) {
  687|  88.2k|  return a.size() == b.size() &&
  ------------------
  |  Branch (687:10): [True: 12.2k, False: 75.9k]
  ------------------
  688|  12.2k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  ------------------
  |  Branch (688:10): [True: 9.91k, False: 2.36k]
  ------------------
  689|  12.2k|           return to_lower(ca) == to_lower(cb);
  690|  12.2k|         });
  691|  88.2k|}
_ZZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_ENKUlccE_clEcc:
  688|   167k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  689|   167k|           return to_lower(ca) == to_lower(cb);
  690|   167k|         });
_ZN7httplib6detail11case_ignore8to_lowerEi:
  654|   359k|inline unsigned char to_lower(int c) {
  655|   359k|  const static unsigned char table[256] = {
  656|   359k|      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  657|   359k|      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  658|   359k|      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  659|   359k|      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  660|   359k|      60,  61,  62,  63,  64,  97,  98,  99,  100, 101, 102, 103, 104, 105, 106,
  661|   359k|      107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
  662|   359k|      122, 91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  663|   359k|      105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  664|   359k|      120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  665|   359k|      135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  666|   359k|      150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  667|   359k|      165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  668|   359k|      180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 224, 225, 226,
  669|   359k|      227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
  670|   359k|      242, 243, 244, 245, 246, 215, 248, 249, 250, 251, 252, 253, 254, 223, 224,
  671|   359k|      225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  672|   359k|      240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  673|   359k|      255,
  674|   359k|  };
  675|   359k|  return table[(unsigned char)(char)c];
  676|   359k|}
_ZN7httplib6Stream5writeEPKc:
12391|  3.13k|inline ssize_t Stream::write(const char *ptr) {
12392|  3.13k|  return write(ptr, strlen(ptr));
12393|  3.13k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEEC2Ev:
 1251|  3.13k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_9FormFieldENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1251|  3.13k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_8FormDataENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1251|  3.13k|  insertion_ordered_multimap() = default;
_ZN7httplib8ResponseC2Ev:
 1921|  3.13k|  Response() = default;
_ZN7httplib8UserDataC2Ev:
 1447|  3.13k|  UserData() = default;
_ZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorE:
16845|  3.13k|                                        Error &error) {
16846|       |  // Auto-add Expect: 100-continue for large bodies
16847|  3.13k|  if (CPPHTTPLIB_EXPECT_100_THRESHOLD > 0 && !req.has_header("Expect")) {
  ------------------
  |  |   90|  3.13k|#define CPPHTTPLIB_EXPECT_100_THRESHOLD 1024
  ------------------
  |  Branch (16847:7): [True: 3.13k, Folded]
  |  Branch (16847:7): [True: 3.13k, False: 0]
  |  Branch (16847:46): [True: 3.13k, False: 0]
  ------------------
16848|  3.13k|    auto body_size = req.body.empty() ? req.content_length_ : req.body.size();
  ------------------
  |  Branch (16848:22): [True: 3.13k, False: 0]
  ------------------
16849|  3.13k|    if (body_size >= CPPHTTPLIB_EXPECT_100_THRESHOLD) {
  ------------------
  |  |   90|  3.13k|#define CPPHTTPLIB_EXPECT_100_THRESHOLD 1024
  ------------------
  |  Branch (16849:9): [True: 0, False: 3.13k]
  ------------------
16850|      0|      req.set_header("Expect", "100-continue");
16851|      0|    }
16852|  3.13k|  }
16853|       |
16854|       |  // Check for Expect: 100-continue
16855|  3.13k|  auto expect_100_continue =
16856|  3.13k|      detail::has_header_token(req.headers, "Expect", "100-continue");
16857|       |
16858|       |  // Send request (skip body if using Expect: 100-continue)
16859|  3.13k|  auto rejected_locally = false;
16860|  3.13k|  auto write_request_success =
16861|  3.13k|      write_request(strm, req, close_connection, error, expect_100_continue,
16862|  3.13k|                    rejected_locally);
16863|       |
16864|       |  // A failed write normally still reads the response below, since the server
16865|       |  // may have answered early (e.g. 413/414) and closed while the body was being
16866|       |  // sent. A request rejected before any byte reached the socket gets no such
16867|       |  // response, and waiting for one would block until the read timeout.
16868|  3.13k|  if (rejected_locally) { return false; }
  ------------------
  |  Branch (16868:7): [True: 0, False: 3.13k]
  ------------------
16869|       |
16870|       |#ifdef CPPHTTPLIB_SSL_ENABLED
16871|       |  if (is_ssl() && !expect_100_continue) {
16872|       |    auto is_proxy_enabled = is_proxy_enabled_for_host(host_);
16873|       |    if (!is_proxy_enabled) {
16874|       |      if (tls::is_peer_closed(socket_.ssl, socket_.sock)) {
16875|       |        error = Error::SSLPeerCouldBeClosed_;
16876|       |        return false;
16877|       |      }
16878|       |    }
16879|       |  }
16880|       |#endif
16881|       |
16882|       |  // Handle Expect: 100-continue.
16883|       |  //
16884|       |  // Wait for an interim/early response by attempting to read the status line
16885|       |  // under a short timeout, instead of trusting raw socket readability. Over
16886|       |  // TLS, post-handshake records (e.g. session tickets) make the socket
16887|       |  // readable without any HTTP response being available; relying on
16888|       |  // `select_read` there caused the body to be withheld forever and the
16889|       |  // request to fail with `Read` (#2458). If no status line arrives within the
16890|       |  // timeout, send the body anyway (matching curl's behavior).
16891|  3.13k|  auto status_line_read = false;
16892|  3.13k|  if (expect_100_continue && write_request_success) {
  ------------------
  |  Branch (16892:7): [True: 0, False: 3.13k]
  |  Branch (16892:30): [True: 0, False: 0]
  ------------------
16893|      0|    if (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND > 0) {
  ------------------
  |  |   94|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
  |  Branch (16893:9): [True: 0, Folded]
  ------------------
16894|      0|      time_t sec = CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND / 1000;
  ------------------
  |  |   94|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
16895|      0|      time_t usec = (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND % 1000) * 1000;
  ------------------
  |  |   94|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
16896|      0|      strm.set_read_timeout(sec, usec);
16897|      0|      status_line_read = read_response_line(strm, req, res, false);
16898|      0|      strm.set_read_timeout(read_timeout_sec_, read_timeout_usec_);
16899|      0|    }
16900|       |
16901|      0|    if (!status_line_read) {
  ------------------
  |  Branch (16901:9): [True: 0, False: 0]
  ------------------
16902|       |      // No interim response within the timeout: send the body and handle the
16903|       |      // response as usual.
16904|      0|      if (!write_request_body(strm, req, error)) { return false; }
  ------------------
  |  Branch (16904:11): [True: 0, False: 0]
  ------------------
16905|      0|      expect_100_continue = false; // Switch to normal response handling
16906|      0|    }
16907|      0|  }
16908|       |
16909|       |  // Receive response and headers
16910|       |  // When using Expect: 100-continue, don't auto-skip `100 Continue` response
16911|  3.13k|  if ((!status_line_read &&
  ------------------
  |  Branch (16911:8): [True: 3.13k, False: 0]
  ------------------
16912|  3.13k|       !read_response_line(strm, req, res, !expect_100_continue)) ||
  ------------------
  |  Branch (16912:8): [True: 554, False: 2.58k]
  ------------------
16913|  2.58k|      !detail::read_headers(strm, res.headers)) {
  ------------------
  |  Branch (16913:7): [True: 711, False: 1.87k]
  ------------------
16914|  1.26k|    if (write_request_success) { error = Error::Read; }
  ------------------
  |  Branch (16914:9): [True: 1.26k, False: 0]
  ------------------
16915|  1.26k|    return false;
16916|  1.26k|  }
16917|       |
16918|  1.87k|  if (!write_request_success) { return false; }
  ------------------
  |  Branch (16918:7): [True: 0, False: 1.87k]
  ------------------
16919|       |
16920|       |  // Handle Expect: 100-continue response
16921|  1.87k|  if (expect_100_continue) {
  ------------------
  |  Branch (16921:7): [True: 0, False: 1.87k]
  ------------------
16922|      0|    if (res.status == StatusCode::Continue_100) {
  ------------------
  |  Branch (16922:9): [True: 0, False: 0]
  ------------------
16923|       |      // Server accepted, send the body
16924|      0|      if (!write_request_body(strm, req, error)) { return false; }
  ------------------
  |  Branch (16924:11): [True: 0, False: 0]
  ------------------
16925|       |
16926|       |      // Read the actual response
16927|      0|      res.headers.clear();
16928|      0|      res.body.clear();
16929|      0|      if (!read_response_line(strm, req, res) ||
  ------------------
  |  Branch (16929:11): [True: 0, False: 0]
  ------------------
16930|      0|          !detail::read_headers(strm, res.headers)) {
  ------------------
  |  Branch (16930:11): [True: 0, False: 0]
  ------------------
16931|      0|        error = Error::Read;
16932|      0|        return false;
16933|      0|      }
16934|      0|    } else {
16935|       |      // A final response came first, so the body this request declared was
16936|       |      // never sent, and the server may still be waiting for it. The
16937|       |      // connection cannot carry another request.
16938|      0|      std::lock_guard<std::mutex> guard(socket_mutex_);
16939|      0|      socket_should_be_closed_when_request_is_done_ = true;
16940|      0|    }
16941|      0|  }
16942|       |
16943|       |  // Body
16944|  1.87k|  if ((res.status != StatusCode::NoContent_204) && req.method != "HEAD" &&
  ------------------
  |  Branch (16944:7): [True: 1.86k, False: 9]
  |  Branch (16944:52): [True: 1.86k, False: 0]
  ------------------
16945|  1.86k|      req.method != "CONNECT") {
  ------------------
  |  Branch (16945:7): [True: 1.86k, False: 0]
  ------------------
16946|       |    // Reject ambiguous framing (RFC 9112 §6.3). Unlike a request, a response
16947|       |    // whose final transfer coding is not chunked is not ambiguous: its body
16948|       |    // runs until the server closes the connection, so it is not rejected.
16949|       |    // HEAD/204 are excluded above and a 304 carries no body.
16950|  1.86k|    if (res.status != StatusCode::NotModified_304) {
  ------------------
  |  Branch (16950:9): [True: 1.85k, False: 12]
  ------------------
16951|  1.85k|      if (detail::has_conflicting_content_length(res.headers)) {
  ------------------
  |  Branch (16951:11): [True: 114, False: 1.73k]
  ------------------
16952|    114|        error = Error::Read;
16953|    114|        return false;
16954|    114|      }
16955|  1.73k|      if (detail::has_faulty_transfer_encoding(res)) {
  ------------------
  |  Branch (16955:11): [True: 511, False: 1.22k]
  ------------------
16956|    511|        std::lock_guard<std::mutex> guard(socket_mutex_);
16957|    511|        socket_should_be_closed_when_request_is_done_ = true;
16958|    511|      }
16959|  1.73k|    }
16960|       |
16961|  1.75k|    auto redirect = follow_location_ && detail::is_redirect(res) &&
  ------------------
  |  Branch (16961:21): [True: 0, False: 1.75k]
  |  Branch (16961:41): [True: 0, False: 0]
  ------------------
16962|      0|                    res.status != StatusCode::NotModified_304;
  ------------------
  |  Branch (16962:21): [True: 0, False: 0]
  ------------------
16963|       |
16964|  1.75k|    if (req.response_handler && !redirect) {
  ------------------
  |  Branch (16964:9): [True: 0, False: 1.75k]
  |  Branch (16964:33): [True: 0, False: 0]
  ------------------
16965|      0|      if (!req.response_handler(res)) {
  ------------------
  |  Branch (16965:11): [True: 0, False: 0]
  ------------------
16966|      0|        error = Error::Canceled;
16967|      0|        return false;
16968|      0|      }
16969|      0|    }
16970|       |
16971|  1.75k|    auto out =
16972|  1.75k|        req.content_receiver
  ------------------
  |  Branch (16972:9): [True: 0, False: 1.75k]
  ------------------
16973|  1.75k|            ? static_cast<ContentReceiverWithProgress>(
16974|      0|                  [&](const char *buf, size_t n, size_t off, size_t len) {
16975|      0|                    if (redirect) { return true; }
16976|      0|                    auto ret = req.content_receiver(buf, n, off, len);
16977|      0|                    if (!ret) { error = Error::Canceled; }
16978|      0|                    return ret;
16979|      0|                  })
16980|  1.75k|            : static_cast<ContentReceiverWithProgress>(
16981|  1.75k|                  [&](const char *buf, size_t n, size_t /*off*/,
16982|  1.75k|                      size_t /*len*/) {
16983|  1.75k|                    assert(res.body.size() + n <= res.body.max_size());
16984|  1.75k|                    if (payload_max_length_ > 0 &&
16985|  1.75k|                        (res.body.size() >= payload_max_length_ ||
16986|  1.75k|                         n > payload_max_length_ - res.body.size())) {
16987|  1.75k|                      return false;
16988|  1.75k|                    }
16989|  1.75k|                    res.body.append(buf, n);
16990|  1.75k|                    return true;
16991|  1.75k|                  });
16992|       |
16993|  1.75k|    auto progress = [&](size_t current, size_t total) {
16994|  1.75k|      if (!req.download_progress || redirect) { return true; }
16995|  1.75k|      auto ret = req.download_progress(current, total);
16996|  1.75k|      if (!ret) { error = Error::Canceled; }
16997|  1.75k|      return ret;
16998|  1.75k|    };
16999|       |
17000|  1.75k|    if (res.has_header("Content-Length")) {
  ------------------
  |  Branch (17000:9): [True: 561, False: 1.18k]
  ------------------
17001|    561|      if (!req.content_receiver) {
  ------------------
  |  Branch (17001:11): [True: 561, False: 0]
  ------------------
17002|    561|        auto len = res.get_header_value_u64("Content-Length");
17003|    561|        if (len > res.body.max_size()) {
  ------------------
  |  Branch (17003:13): [True: 67, False: 494]
  ------------------
17004|     67|          error = Error::Read;
17005|     67|          return false;
17006|     67|        }
17007|       |        // Content-Length is only the server's claim, so reserve no more than
17008|       |        // payload_max_length_ allows, nor more than 1 MiB before any of the
17009|       |        // body has arrived. A longer body grows as it is read.
17010|    494|        auto reserve_len =
17011|    494|            (std::min)(static_cast<size_t>(len), size_t(1024 * 1024));
17012|    494|        if (payload_max_length_ > 0) {
  ------------------
  |  Branch (17012:13): [True: 494, False: 0]
  ------------------
17013|    494|          reserve_len = (std::min)(reserve_len, payload_max_length_);
17014|    494|        }
17015|    494|        res.body.reserve(reserve_len);
17016|    494|      }
17017|    561|    }
17018|       |
17019|  1.68k|    if (res.status != StatusCode::NotModified_304) {
  ------------------
  |  Branch (17019:9): [True: 1.67k, False: 12]
  ------------------
17020|  1.67k|      auto content_status = 0;
17021|  1.67k|      auto max_length = (!has_payload_max_length_ && req.content_receiver)
  ------------------
  |  Branch (17021:26): [True: 1.67k, False: 0]
  |  Branch (17021:54): [True: 0, False: 1.67k]
  ------------------
17022|  1.67k|                            ? (std::numeric_limits<size_t>::max)()
17023|  1.67k|                            : payload_max_length_;
17024|  1.67k|      if (!detail::read_content(strm, res, max_length, content_status,
  ------------------
  |  Branch (17024:11): [True: 1.19k, False: 480]
  ------------------
17025|  1.67k|                                std::move(progress), std::move(out),
17026|  1.67k|                                decompress_)) {
17027|  1.19k|        if (error != Error::Canceled) {
  ------------------
  |  Branch (17027:13): [True: 1.19k, False: 0]
  ------------------
17028|       |          // Tell the caller apart from a plain read failure when the body was
17029|       |          // over the payload limit or could not be decoded because of its
17030|       |          // Content-Encoding.
17031|  1.19k|          switch (content_status) {
17032|     15|          case StatusCode::PayloadTooLarge_413:
  ------------------
  |  Branch (17032:11): [True: 15, False: 1.17k]
  ------------------
17033|     15|            error = Error::ExceedMaxPayloadSize;
17034|     15|            break;
17035|      2|          case StatusCode::UnsupportedMediaType_415:
  ------------------
  |  Branch (17035:11): [True: 2, False: 1.18k]
  ------------------
17036|      2|            error = Error::UnsupportedContentEncoding;
17037|      2|            break;
17038|      0|          case StatusCode::InternalServerError_500:
  ------------------
  |  Branch (17038:11): [True: 0, False: 1.19k]
  ------------------
17039|      0|            error = Error::Compression;
17040|      0|            break;
17041|  1.17k|          default: error = Error::Read; break;
  ------------------
  |  Branch (17041:11): [True: 1.17k, False: 17]
  ------------------
17042|  1.19k|          }
17043|  1.19k|        }
17044|  1.19k|        return false;
17045|  1.19k|      }
17046|  1.67k|    }
17047|  1.68k|  }
17048|       |
17049|       |  // Log
17050|    501|  output_log(req, res);
17051|       |
17052|    501|  return true;
17053|  1.87k|}
_ZNK7httplib7Request10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12004|  21.9k|inline bool Request::has_header(const std::string &key) const {
12005|  21.9k|  return detail::has_header(headers, key);
12006|  21.9k|}
_ZN7httplib6detail10has_headerERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 8353|  24.7k|inline bool has_header(const Headers &headers, const std::string &key) {
 8354|  24.7k|  if (is_prohibited_header_name(key)) { return false; }
  ------------------
  |  Branch (8354:7): [True: 0, False: 24.7k]
  ------------------
 8355|  24.7k|  return headers.find(key) != headers.end();
 8356|  24.7k|}
_ZN7httplib6detail25is_prohibited_header_nameERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8345|  24.7k|inline bool is_prohibited_header_name(const std::string &name) {
 8346|       |  // Field names are case-insensitive (RFC 9110 §5.1)
 8347|  24.7k|  return case_ignore::equal(name, "REMOTE_ADDR") ||
  ------------------
  |  Branch (8347:10): [True: 0, False: 24.7k]
  ------------------
 8348|  24.7k|         case_ignore::equal(name, "REMOTE_PORT") ||
  ------------------
  |  Branch (8348:10): [True: 0, False: 24.7k]
  ------------------
 8349|  24.7k|         case_ignore::equal(name, "LOCAL_ADDR") ||
  ------------------
  |  Branch (8349:10): [True: 0, False: 24.7k]
  ------------------
 8350|  24.7k|         case_ignore::equal(name, "LOCAL_PORT");
  ------------------
  |  Branch (8350:10): [True: 0, False: 24.7k]
  ------------------
 8351|  24.7k|}
_ZN7httplib6detail11case_ignore5equalILm12EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  695|  49.5k|inline bool equal(const std::string &a, const char (&b)[N]) {
  696|  49.5k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (696:10): [True: 0, False: 49.5k]
  ------------------
  697|      0|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (697:10): [True: 0, False: 0]
  ------------------
  698|      0|           return to_lower(ca) == to_lower(cb);
  699|      0|         });
  700|  49.5k|}
_ZN7httplib6detail11case_ignore5equalILm11EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  695|  49.5k|inline bool equal(const std::string &a, const char (&b)[N]) {
  696|  49.5k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (696:10): [True: 6.27k, False: 43.3k]
  ------------------
  697|  6.27k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (697:10): [True: 0, False: 6.27k]
  ------------------
  698|  6.27k|           return to_lower(ca) == to_lower(cb);
  699|  6.27k|         });
  700|  49.5k|}
_ZZN7httplib6detail11case_ignore5equalILm11EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  697|  6.27k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  698|  6.27k|           return to_lower(ca) == to_lower(cb);
  699|  6.27k|         });
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4findERKS8_:
 1297|  29.2k|  const_iterator find(const std::string &key) const {
 1298|  29.2k|    auto i = index_of(key);
 1299|  29.2k|    return i == npos() ? end() : make_citer(i, i);
  ------------------
  |  Branch (1299:12): [True: 26.1k, False: 3.08k]
  ------------------
 1300|  29.2k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE8index_ofERKS8_:
 1382|  42.7k|  size_type index_of(const std::string &key) const {
 1383|   118k|    for (size_type i = 0; i < entries_.size(); i++) {
  ------------------
  |  Branch (1383:27): [True: 82.6k, False: 36.2k]
  ------------------
 1384|  82.6k|      if (keys_equal(entries_[i].first, key)) { return i; }
  ------------------
  |  Branch (1384:11): [True: 6.49k, False: 76.1k]
  ------------------
 1385|  82.6k|    }
 1386|  36.2k|    return npos();
 1387|  42.7k|  }
_ZN7httplib7Request10set_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_:
12018|  8.37k|                                const std::string &val) {
12019|  8.37k|  detail::set_header(headers, key, val);
12020|  8.37k|}
_ZN7httplib6detail10set_headerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SE_:
 8430|  8.37k|                       const std::string &val) {
 8431|  8.37k|  if (fields::is_field_valid(key, val)) { headers.emplace(key, val); }
  ------------------
  |  Branch (8431:7): [True: 8.37k, False: 0]
  ------------------
 8432|  8.37k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE7emplaceIJRKS8_SE_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1280|  31.5k|  template <typename... Args> iterator emplace(Args &&...args) {
 1281|  31.5k|    entries_.emplace_back(std::forward<Args>(args)...);
 1282|  31.5k|    return make_iter(entries_.size() - 1, npos());
 1283|  31.5k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE9make_iterEmm:
 1389|  60.0k|  iterator make_iter(size_type idx, size_type key_idx) {
 1390|  60.0k|    return iterator(entries_.data(), idx, entries_.size(), key_idx);
 1391|  60.0k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEC2EPSE_mmm:
 1235|  60.0k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail16has_header_tokenERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SF_:
 8402|  3.13k|                             const std::string &token) {
 8403|       |  // RFC 9110 7.6.1: a comma-separated token list field such as Connection may
 8404|       |  // carry several tokens, and RFC 9110 5.3 lets that list be split across
 8405|       |  // several lines. Match complete tokens rather than searching the raw value,
 8406|       |  // so that a value such as "notupgrade" is not read as the token "upgrade".
 8407|  3.13k|  auto rng = headers.equal_range(key);
 8408|  3.13k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (8408:29): [True: 0, False: 3.13k]
  ------------------
 8409|      0|    const auto &value = it->second;
 8410|      0|    if (split_find(value.data(), value.data() + value.size(), ',',
  ------------------
  |  Branch (8410:9): [True: 0, False: 0]
  ------------------
 8411|      0|                   [&](const char *b, const char *e) {
 8412|      0|                     return case_ignore::equal(std::string(b, e), token);
 8413|      0|                   })) {
 8414|      0|      return true;
 8415|      0|    }
 8416|      0|  }
 8417|  3.13k|  return false;
 8418|  3.13k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1317|  8.71k|  equal_range(const std::string &key) const {
 1318|  8.71k|    auto i = index_of(key);
 1319|  8.71k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1319:12): [True: 6.31k, False: 2.40k]
  ------------------
 1320|  8.71k|                       : std::make_pair(make_citer(i, i), end());
 1321|  8.71k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEptEv:
 1184|  5.91k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail4trimEPKcS2_mm:
 6243|  16.1k|                                      size_t right) {
 6244|  24.4k|  while (b + left < e && is_space_or_tab(b[left])) {
  ------------------
  |  Branch (6244:10): [True: 24.3k, False: 126]
  |  Branch (6244:26): [True: 8.30k, False: 15.9k]
  ------------------
 6245|  8.30k|    left++;
 6246|  8.30k|  }
 6247|  24.3k|  while (right > 0 && is_space_or_tab(b[right - 1])) {
  ------------------
  |  Branch (6247:10): [True: 24.2k, False: 134]
  |  Branch (6247:23): [True: 8.27k, False: 15.9k]
  ------------------
 6248|  8.27k|    right--;
 6249|  8.27k|  }
 6250|  16.1k|  return std::make_pair(left, right);
 6251|  16.1k|}
_ZN7httplib6detail15is_space_or_tabEc:
 6096|  98.3k|inline bool is_space_or_tab(char c) { return c == ' ' || c == '\t'; }
  ------------------
  |  Branch (6096:46): [True: 28.7k, False: 69.5k]
  |  Branch (6096:58): [True: 569, False: 69.0k]
  ------------------
_ZN7httplib10ClientImpl13write_requestERNS_6StreamERNS_7RequestEbRNS_5ErrorEbRb:
16532|  3.13k|                                      bool skip_body, bool &rejected_locally) {
16533|  3.13k|  rejected_locally = false;
16534|       |
16535|       |  // Prepare additional headers
16536|  3.13k|  if (close_connection) {
  ------------------
  |  Branch (16536:7): [True: 0, False: 3.13k]
  ------------------
16537|      0|    if (!req.has_header("Connection")) {
  ------------------
  |  Branch (16537:9): [True: 0, False: 0]
  ------------------
16538|      0|      req.set_header("Connection", "close");
16539|      0|    }
16540|      0|  }
16541|       |
16542|  3.13k|  std::string ct_for_defaults;
16543|  3.13k|  if (!req.has_header("Content-Type") && !req.body.empty()) {
  ------------------
  |  Branch (16543:7): [True: 3.13k, False: 0]
  |  Branch (16543:7): [True: 0, False: 3.13k]
  |  Branch (16543:42): [True: 0, False: 3.13k]
  ------------------
16544|      0|    ct_for_defaults = "text/plain";
16545|      0|  }
16546|  3.13k|  prepare_default_headers(req, false, ct_for_defaults);
16547|       |
16548|  3.13k|  if (req.body.empty()) {
  ------------------
  |  Branch (16548:7): [True: 3.13k, False: 0]
  ------------------
16549|  3.13k|    if (req.content_provider_) {
  ------------------
  |  Branch (16549:9): [True: 0, False: 3.13k]
  ------------------
16550|      0|      if (!req.is_chunked_content_provider_) {
  ------------------
  |  Branch (16550:11): [True: 0, False: 0]
  ------------------
16551|      0|        if (!req.has_header("Content-Length")) {
  ------------------
  |  Branch (16551:13): [True: 0, False: 0]
  ------------------
16552|      0|          auto length = std::to_string(req.content_length_);
16553|      0|          req.set_header("Content-Length", length);
16554|      0|        }
16555|      0|      }
16556|  3.13k|    } else {
16557|  3.13k|      if (req.method == "POST" || req.method == "PUT" ||
  ------------------
  |  Branch (16557:11): [True: 712, False: 2.42k]
  |  Branch (16557:35): [True: 950, False: 1.47k]
  ------------------
16558|  2.09k|          req.method == "PATCH") {
  ------------------
  |  Branch (16558:11): [True: 435, False: 1.04k]
  ------------------
16559|  2.09k|        req.set_header("Content-Length", "0");
16560|  2.09k|      }
16561|  3.13k|    }
16562|  3.13k|  }
16563|       |
16564|  3.13k|  add_credential_headers(req);
16565|       |
16566|       |  // Request line and headers
16567|  3.13k|  {
16568|  3.13k|    detail::BufferStream bstrm;
16569|       |
16570|  3.13k|    auto path_with_query = make_request_target(req);
16571|       |
16572|       |    // The query already came in through `req.path`; still populate
16573|       |    // `req.params` for handlers/users who read them.
16574|  3.13k|    auto query_part = detail::query_of(req.path);
16575|  3.13k|    if (!query_part.empty()) {
  ------------------
  |  Branch (16575:9): [True: 0, False: 3.13k]
  ------------------
16576|      0|      detail::parse_query_text(query_part, req.params);
16577|      0|    }
16578|       |
16579|       |    // Write request line and headers
16580|  3.13k|    if (detail::write_request_line(bstrm, req.method, path_with_query) < 0) {
  ------------------
  |  Branch (16580:9): [True: 0, False: 3.13k]
  ------------------
16581|       |      // A rejected method (not a token, e.g. carrying CR/LF) or target (e.g.
16582|       |      // CR/LF in a caller-supplied path under set_path_encode(false)) must
16583|       |      // fail the request cleanly instead of emitting a request-line-less,
16584|       |      // header-injecting request.
16585|      0|      error = Error::Write;
16586|      0|      rejected_locally = true;
16587|      0|      return false;
16588|      0|    }
16589|  3.13k|    if (!detail::check_and_write_headers(bstrm, req.headers, header_writer_,
  ------------------
  |  Branch (16589:9): [True: 0, False: 3.13k]
  ------------------
16590|  3.13k|                                         error)) {
16591|      0|      rejected_locally = true;
16592|      0|      return false;
16593|      0|    }
16594|       |
16595|       |    // Flush buffer
16596|  3.13k|    auto &data = bstrm.get_buffer();
16597|  3.13k|    if (!detail::write_data(strm, data.data(), data.size())) {
  ------------------
  |  Branch (16597:9): [True: 0, False: 3.13k]
  ------------------
16598|      0|      error = Error::Write;
16599|      0|      return false;
16600|      0|    }
16601|  3.13k|  }
16602|       |
16603|       |  // After sending request line and headers, wait briefly for an early server
16604|       |  // response (e.g. 4xx) and avoid sending a potentially large request body
16605|       |  // unnecessarily. This workaround is only enabled on Windows because Unix
16606|       |  // platforms surface write errors (EPIPE) earlier; on Windows kernel send
16607|       |  // buffering can accept large writes even when the peer already responded.
16608|       |  // Check the stream first (which covers SSL via `is_readable()`), then
16609|       |  // fall back to select on the socket. Only perform the wait for very large
16610|       |  // request bodies to avoid interfering with normal small requests and
16611|       |  // reduce side-effects. Poll briefly (up to 50ms as default) for an early
16612|       |  // response. Skip this check when using Expect: 100-continue, as the protocol
16613|       |  // handles early responses properly.
16614|       |#if defined(_WIN32)
16615|       |  if (!skip_body &&
16616|       |      req.body.size() > CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_THRESHOLD &&
16617|       |      req.path.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
16618|       |    auto start = std::chrono::high_resolution_clock::now();
16619|       |
16620|       |    for (;;) {
16621|       |      // Prefer socket-level readiness to avoid SSL_pending() false-positives
16622|       |      // from SSL internals. If the underlying socket is readable, assume an
16623|       |      // early response may be present.
16624|       |      auto sock = strm.socket();
16625|       |      if (sock != INVALID_SOCKET && detail::select_read(sock, 0, 0) > 0) {
16626|       |        return false;
16627|       |      }
16628|       |
16629|       |      // Fallback to stream-level check for non-socket streams or when the
16630|       |      // socket isn't reporting readable. Avoid using `is_readable()` for
16631|       |      // SSL, since `SSL_pending()` may report buffered records that do not
16632|       |      // indicate a complete application-level response yet.
16633|       |      if (!is_ssl() && strm.is_readable()) { return false; }
16634|       |
16635|       |      auto now = std::chrono::high_resolution_clock::now();
16636|       |      auto elapsed =
16637|       |          std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
16638|       |              .count();
16639|       |      if (elapsed >= CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_TIMEOUT_MSECOND) {
16640|       |        break;
16641|       |      }
16642|       |
16643|       |      std::this_thread::sleep_for(std::chrono::milliseconds(1));
16644|       |    }
16645|       |  }
16646|       |#endif
16647|       |
16648|       |  // Body
16649|  3.13k|  if (skip_body) { return true; }
  ------------------
  |  Branch (16649:7): [True: 0, False: 3.13k]
  ------------------
16650|       |
16651|  3.13k|  return write_request_body(strm, req, error);
16652|  3.13k|}
_ZN7httplib10ClientImpl23prepare_default_headersERNS_7RequestEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
15757|  3.13k|                                                const std::string &ct) {
15758|  3.13k|  (void)for_stream;
15759|       |  // Default headers are meant for the origin and may carry its credentials, so
15760|       |  // keep them off the CONNECT request the proxy reads.
15761|  3.13k|  if (r.method != "CONNECT") {
  ------------------
  |  Branch (15761:7): [True: 3.13k, False: 0]
  ------------------
15762|  3.13k|    for (const auto &header : default_headers_) {
  ------------------
  |  Branch (15762:29): [True: 0, False: 3.13k]
  ------------------
15763|      0|      if (!r.has_header(header.first)) { r.headers.insert(header); }
  ------------------
  |  Branch (15763:11): [True: 0, False: 0]
  ------------------
15764|      0|    }
15765|  3.13k|  }
15766|       |
15767|       |  // RFC 9110 5.3 recommends sending control data such as Host first, so
15768|       |  // prepend it rather than appending it after the caller's own fields.
15769|  3.13k|  if (!r.has_header("Host")) {
  ------------------
  |  Branch (15769:7): [True: 3.13k, False: 0]
  ------------------
15770|  3.13k|    r.headers.emplace_front(
15771|  3.13k|        "Host", detail::make_default_host_header_value(host_, port_, is_ssl(),
15772|  3.13k|                                                       address_family_));
15773|  3.13k|  }
15774|       |
15775|  3.13k|  if (!r.has_header("Accept")) { r.headers.emplace("Accept", "*/*"); }
  ------------------
  |  Branch (15775:7): [True: 3.13k, False: 0]
  ------------------
15776|       |
15777|  3.13k|  if (!r.content_receiver) {
  ------------------
  |  Branch (15777:7): [True: 3.13k, False: 0]
  ------------------
15778|  3.13k|    if (!r.has_header("Accept-Encoding")) {
  ------------------
  |  Branch (15778:9): [True: 3.13k, False: 0]
  ------------------
15779|  3.13k|      std::string accept_encoding;
15780|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
15781|       |      accept_encoding = "br";
15782|       |#endif
15783|  3.13k|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
15784|  3.13k|      if (!accept_encoding.empty()) { accept_encoding += ", "; }
  ------------------
  |  Branch (15784:11): [True: 0, False: 3.13k]
  ------------------
15785|  3.13k|      accept_encoding += "gzip, deflate";
15786|  3.13k|#endif
15787|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
15788|       |      if (!accept_encoding.empty()) { accept_encoding += ", "; }
15789|       |      accept_encoding += "zstd";
15790|       |#endif
15791|  3.13k|      r.set_header("Accept-Encoding", accept_encoding);
15792|  3.13k|    }
15793|       |
15794|  3.13k|    detail::add_default_user_agent_header(r);
15795|  3.13k|  }
15796|       |
15797|  3.13k|  if (!r.body.empty()) {
  ------------------
  |  Branch (15797:7): [True: 0, False: 3.13k]
  ------------------
15798|      0|    if (!ct.empty() && !r.has_header("Content-Type")) {
  ------------------
  |  Branch (15798:9): [True: 0, False: 0]
  |  Branch (15798:9): [True: 0, False: 0]
  |  Branch (15798:24): [True: 0, False: 0]
  ------------------
15799|      0|      r.headers.emplace("Content-Type", ct);
15800|      0|    }
15801|      0|    if (!r.has_header("Content-Length")) {
  ------------------
  |  Branch (15801:9): [True: 0, False: 0]
  ------------------
15802|      0|      r.headers.emplace("Content-Length", std::to_string(r.body.size()));
15803|      0|    }
15804|      0|  }
15805|  3.13k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1258|  6.27k|  iterator begin() { return make_iter(0, npos()); }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1259|  14.9k|  iterator end() { return make_iter(entries_.size(), npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEneISE_EEbRKNSC_IT_EE:
 1226|  28.6k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1227|  28.6k|      return idx_ != rhs.idx_;
 1228|  28.6k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEdeEv:
 1183|  14.6k|    reference operator*() const { return data_[idx_]; }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEppEv:
 1186|  17.5k|    iterator_t &operator++() {
 1187|       |      // Saturating, so that advancing past the last entry of a key stays at
 1188|       |      // end() instead of running off the container.
 1189|  17.5k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1189:11): [True: 0, False: 17.5k]
  ------------------
 1190|  17.5k|      ++idx_;
 1191|  17.5k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1191:11): [True: 2.88k, False: 14.6k]
  ------------------
 1192|  4.17k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1192:16): [True: 3.34k, False: 827]
  |  Branch (1192:32): [True: 1.29k, False: 2.05k]
  ------------------
 1193|  1.29k|          ++idx_;
 1194|  1.29k|        }
 1195|  2.88k|      }
 1196|  17.5k|      return *this;
 1197|  17.5k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEE7matchesEm:
 1237|  3.34k|    bool matches(size_type i) const {
 1238|  3.34k|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1239|  3.34k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE13emplace_frontIJRA5_KcS8_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1287|  3.13k|  template <typename... Args> iterator emplace_front(Args &&...args) {
 1288|  3.13k|    entries_.emplace(entries_.begin(), std::forward<Args>(args)...);
 1289|  3.13k|    return make_iter(0, npos());
 1290|  3.13k|  }
_ZN7httplib6detail30make_default_host_header_valueERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEibi:
12980|  3.13k|                                                  int address_family) {
12981|  3.13k|  if (address_family == AF_UNIX) { return "localhost"; }
  ------------------
  |  Branch (12981:7): [True: 0, False: 3.13k]
  ------------------
12982|  3.13k|  return make_host_and_port_string(host, port, is_ssl);
12983|  3.13k|}
_ZN7httplib6detail25make_host_and_port_stringERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEib:
12957|  3.13k|                                             bool is_ssl) {
12958|  3.13k|  auto result = prepare_host_string(host);
12959|       |
12960|       |  // Append port if not default
12961|  3.13k|  if ((!is_ssl && port == 80) || (is_ssl && port == 443)) {
  ------------------
  |  Branch (12961:8): [True: 3.13k, False: 0]
  |  Branch (12961:19): [True: 0, False: 3.13k]
  |  Branch (12961:35): [True: 0, False: 3.13k]
  |  Branch (12961:45): [True: 0, False: 0]
  ------------------
12962|      0|    ; // do nothing
12963|  3.13k|  } else {
12964|  3.13k|    result += ":" + std::to_string(port);
12965|  3.13k|  }
12966|       |
12967|  3.13k|  return result;
12968|  3.13k|}
_ZN7httplib6detail19prepare_host_stringERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12944|  3.13k|inline std::string prepare_host_string(const std::string &host) {
12945|       |  // Enclose IPv6 address in brackets (but not if already enclosed)
12946|  3.13k|  if (host.find(':') == std::string::npos ||
  ------------------
  |  Branch (12946:7): [True: 3.13k, False: 0]
  ------------------
12947|  3.13k|      (!host.empty() && host[0] == '[')) {
  ------------------
  |  Branch (12947:8): [True: 0, False: 0]
  |  Branch (12947:25): [True: 0, False: 0]
  ------------------
12948|       |    // IPv4, hostname, or already bracketed IPv6
12949|  3.13k|    return host;
12950|  3.13k|  } else {
12951|       |    // IPv6 address without brackets
12952|      0|    return "[" + host + "]";
12953|      0|  }
12954|  3.13k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE7emplaceIJRA7_KcRA4_SD_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1280|  3.13k|  template <typename... Args> iterator emplace(Args &&...args) {
 1281|  3.13k|    entries_.emplace_back(std::forward<Args>(args)...);
 1282|  3.13k|    return make_iter(entries_.size() - 1, npos());
 1283|  3.13k|  }
_ZN7httplib6detail29add_default_user_agent_headerERNS_7RequestE:
12985|  3.13k|inline void add_default_user_agent_header(Request &req) {
12986|  3.13k|#ifndef CPPHTTPLIB_NO_DEFAULT_USER_AGENT
12987|  3.13k|  if (!req.has_header("User-Agent")) {
  ------------------
  |  Branch (12987:7): [True: 3.13k, False: 0]
  ------------------
12988|  3.13k|    req.set_header("User-Agent",
12989|  3.13k|                   std::string("cpp-httplib/") + CPPHTTPLIB_VERSION);
  ------------------
  |  |   11|  3.13k|#define CPPHTTPLIB_VERSION "0.62.0"
  ------------------
12990|  3.13k|  }
12991|       |#else
12992|       |  (void)req;
12993|       |#endif
12994|  3.13k|}
_ZN7httplib10ClientImpl22add_credential_headersERNS_7RequestE:
16509|  3.13k|inline void ClientImpl::add_credential_headers(Request &req) {
16510|       |  // A CONNECT request is read by the proxy; everything sent through the tunnel
16511|       |  // it opens is read by the origin. Each credential goes only to its own hop.
16512|  3.13k|  auto is_connect = req.method == "CONNECT";
16513|       |
16514|  3.13k|  if (!is_connect) {
  ------------------
  |  Branch (16514:7): [True: 3.13k, False: 0]
  ------------------
16515|  3.13k|    detail::add_authorization_header(req, basic_auth_username_,
16516|  3.13k|                                     basic_auth_password_,
16517|  3.13k|                                     bearer_token_auth_token_, false);
16518|  3.13k|  }
16519|       |
16520|       |  // Proxy-Authorization is only sent when the proxy reads this message —
16521|       |  // otherwise NO_PROXY-matched requests, and requests inside a TLS tunnel,
16522|       |  // would leak proxy credentials to the destination server.
16523|  3.13k|  if (is_proxy_enabled_for_host(host_) && (!is_ssl() || is_connect)) {
  ------------------
  |  Branch (16523:7): [True: 0, False: 3.13k]
  |  Branch (16523:44): [True: 0, False: 0]
  |  Branch (16523:57): [True: 0, False: 0]
  ------------------
16524|      0|    detail::add_authorization_header(req, proxy_basic_auth_username_,
16525|      0|                                     proxy_basic_auth_password_,
16526|      0|                                     proxy_bearer_token_auth_token_, true);
16527|      0|  }
16528|  3.13k|}
_ZN7httplib6detail24add_authorization_headerERNS_7RequestERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_SB_b:
11983|  3.13k|                                     const std::string &token, bool is_proxy) {
11984|  3.13k|  if (req.has_header(is_proxy ? "Proxy-Authorization" : "Authorization")) {
  ------------------
  |  Branch (11984:7): [True: 0, False: 3.13k]
  |  Branch (11984:22): [True: 0, False: 3.13k]
  ------------------
11985|      0|    return;
11986|      0|  }
11987|  3.13k|  if (!username.empty() || !password.empty()) {
  ------------------
  |  Branch (11987:7): [True: 0, False: 3.13k]
  |  Branch (11987:28): [True: 0, False: 3.13k]
  ------------------
11988|      0|    req.headers.insert(
11989|      0|        make_basic_authentication_header(username, password, is_proxy));
11990|  3.13k|  } else if (!token.empty()) {
  ------------------
  |  Branch (11990:14): [True: 0, False: 3.13k]
  ------------------
11991|      0|    req.headers.insert(
11992|      0|        make_bearer_token_authentication_header(token, is_proxy));
11993|      0|  }
11994|  3.13k|}
_ZNK7httplib10ClientImpl25is_proxy_enabled_for_hostERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
15488|  3.13k|ClientImpl::is_proxy_enabled_for_host(const std::string &host) const {
15489|  3.13k|  if (proxy_host_.empty() || proxy_port_ == -1) { return false; }
  ------------------
  |  Branch (15489:7): [True: 3.13k, False: 0]
  |  Branch (15489:30): [True: 0, False: 0]
  ------------------
15490|      0|  if (no_proxy_entries_.empty()) { return true; }
  ------------------
  |  Branch (15490:7): [True: 0, False: 0]
  ------------------
15491|       |  // host_ is const so its normalized form is invariant; cache it. The
15492|       |  // cross-host path (setup_redirect_client passing next_host) re-normalizes.
15493|      0|  if (host == host_) {
  ------------------
  |  Branch (15493:7): [True: 0, False: 0]
  ------------------
15494|      0|    if (!host_normalized_valid_) {
  ------------------
  |  Branch (15494:9): [True: 0, False: 0]
  ------------------
15495|      0|      host_normalized_ = detail::normalize_target(host_);
15496|      0|      host_normalized_valid_ = true;
15497|      0|    }
15498|      0|    return !detail::host_matches_no_proxy(host_normalized_, no_proxy_entries_);
15499|      0|  }
15500|      0|  auto target = detail::normalize_target(host);
15501|      0|  return !detail::host_matches_no_proxy(target, no_proxy_entries_);
15502|      0|}
_ZN7httplib6detail12BufferStreamC2Ev:
 3851|  3.13k|  BufferStream() = default;
_ZNK7httplib10ClientImpl19make_request_targetERKNS_7RequestE:
16501|  3.13k|inline std::string ClientImpl::make_request_target(const Request &req) const {
16502|  3.13k|  auto target = detail::encode_request_target(req.path, path_encode_);
16503|  3.13k|  if (detail::query_of(req.path).empty() && !req.params.empty()) {
  ------------------
  |  Branch (16503:7): [True: 3.13k, False: 0]
  |  Branch (16503:7): [True: 0, False: 3.13k]
  |  Branch (16503:45): [True: 0, False: 3.13k]
  ------------------
16504|      0|    target = append_query_params(target, req.params);
16505|      0|  }
16506|  3.13k|  return target;
16507|  3.13k|}
_ZN7httplib6detail21encode_request_targetERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEb:
 9380|  3.13k|                                         bool path_encode) {
 9381|       |  // The fragment stays with the client (RFC 9110 §7.1).
 9382|  3.13k|  auto target = uri.substr(0, uri.find('#'));
 9383|       |
 9384|       |  // `substr(0, npos)` yields the whole string, which is what the no-query
 9385|       |  // case needs.
 9386|  3.13k|  auto query_pos = target.find('?');
 9387|  3.13k|  auto path_part = target.substr(0, query_pos);
 9388|  3.13k|  std::string query_part;
 9389|  3.13k|  if (query_pos != std::string::npos) {
  ------------------
  |  Branch (9389:7): [True: 0, False: 3.13k]
  ------------------
 9390|      0|    query_part = target.substr(query_pos + 1);
 9391|      0|  }
 9392|       |
 9393|  3.13k|  auto result = path_encode ? encode_path(path_part) : std::move(path_part);
  ------------------
  |  Branch (9393:17): [True: 3.13k, False: 0]
  ------------------
 9394|       |
 9395|  3.13k|  if (!query_part.empty()) {
  ------------------
  |  Branch (9395:7): [True: 0, False: 3.13k]
  ------------------
 9396|       |    // When path encoding is disabled the caller has supplied an already-encoded
 9397|       |    // target and expects the exact bytes to be sent on the wire, so skip
 9398|       |    // normalization for the query too. Normalizing would decode-then-re-encode
 9399|       |    // it and corrupt pre-encoded binary payloads (e.g. turning `%20` into `+`,
 9400|       |    // which a strict RFC 3986 server decodes back as `+`, not a space).
 9401|      0|    if (path_encode) {
  ------------------
  |  Branch (9401:9): [True: 0, False: 0]
  ------------------
 9402|      0|      auto normalized = normalize_query_string(query_part);
 9403|      0|      if (!normalized.empty()) {
  ------------------
  |  Branch (9403:11): [True: 0, False: 0]
  ------------------
 9404|      0|        result += '?';
 9405|      0|        result += normalized;
 9406|      0|      }
 9407|      0|    } else {
 9408|      0|      result += '?';
 9409|      0|      result += query_part;
 9410|      0|    }
 9411|      0|  }
 9412|       |
 9413|  3.13k|  return result;
 9414|  3.13k|}
_ZN7httplib6detail11encode_pathERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6053|  3.13k|inline std::string encode_path(const std::string &s) {
 6054|  3.13k|  std::string result;
 6055|  3.13k|  result.reserve(s.size());
 6056|       |
 6057|  6.27k|  for (size_t i = 0; s[i]; i++) {
  ------------------
  |  Branch (6057:22): [True: 3.13k, False: 3.13k]
  ------------------
 6058|  3.13k|    switch (s[i]) {
 6059|      0|    case ' ': result += "%20"; break;
  ------------------
  |  Branch (6059:5): [True: 0, False: 3.13k]
  ------------------
 6060|      0|    case '+': result += "%2B"; break;
  ------------------
  |  Branch (6060:5): [True: 0, False: 3.13k]
  ------------------
 6061|      0|    case '\'': result += "%27"; break;
  ------------------
  |  Branch (6061:5): [True: 0, False: 3.13k]
  ------------------
 6062|      0|    case ',': result += "%2C"; break;
  ------------------
  |  Branch (6062:5): [True: 0, False: 3.13k]
  ------------------
 6063|       |    // case ':': result += "%3A"; break; // ok? probably...
 6064|      0|    case ';': result += "%3B"; break;
  ------------------
  |  Branch (6064:5): [True: 0, False: 3.13k]
  ------------------
 6065|  3.13k|    default:
  ------------------
  |  Branch (6065:5): [True: 3.13k, False: 0]
  ------------------
 6066|  3.13k|      auto c = static_cast<uint8_t>(s[i]);
 6067|       |      // Control characters (incl. CR/LF) and non-ASCII bytes are not allowed
 6068|       |      // in a request-target as-is.
 6069|  3.13k|      if (c < 0x20 || c == 0x7f || c >= 0x80) {
  ------------------
  |  Branch (6069:11): [True: 0, False: 3.13k]
  |  Branch (6069:23): [True: 0, False: 3.13k]
  |  Branch (6069:36): [True: 0, False: 3.13k]
  ------------------
 6070|      0|        result += '%';
 6071|      0|        char hex[4];
 6072|      0|        auto len = snprintf(hex, sizeof(hex) - 1, "%02X", c);
 6073|      0|        assert(len == 2);
  ------------------
  |  Branch (6073:9): [True: 0, False: 0]
  ------------------
 6074|      0|        result.append(hex, static_cast<size_t>(len));
 6075|  3.13k|      } else {
 6076|  3.13k|        result += s[i];
 6077|  3.13k|      }
 6078|  3.13k|      break;
 6079|  3.13k|    }
 6080|  3.13k|  }
 6081|       |
 6082|  3.13k|  return result;
 6083|  3.13k|}
_ZN7httplib6detail5splitEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 6303|  1.27k|                  std::function<void(const char *, const char *)> fn) {
 6304|  1.27k|  return split(b, e, d, (std::numeric_limits<size_t>::max)(), std::move(fn));
 6305|  1.27k|}
_ZN7httplib6detail5splitEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 6308|  1.27k|                  std::function<void(const char *, const char *)> fn) {
 6309|  1.27k|  size_t i = 0;
 6310|  1.27k|  size_t beg = 0;
 6311|  1.27k|  size_t count = 1;
 6312|       |
 6313|   125k|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6313:10): [True: 125k, False: 0]
  |  Branch (6313:10): [True: 123k, False: 1.27k]
  ------------------
 6314|   123k|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6314:9): [True: 15.0k, False: 108k]
  |  Branch (6314:22): [True: 15.0k, False: 0]
  ------------------
 6315|  15.0k|      auto r = trim(b, e, beg, i);
 6316|  15.0k|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6316:11): [True: 4.80k, False: 10.2k]
  ------------------
 6317|  15.0k|      beg = i + 1;
 6318|  15.0k|      count++;
 6319|  15.0k|    }
 6320|   123k|    i++;
 6321|   123k|  }
 6322|       |
 6323|  1.27k|  if (i) {
  ------------------
  |  Branch (6323:7): [True: 1.09k, False: 188]
  ------------------
 6324|  1.09k|    auto r = trim(b, e, beg, i);
 6325|  1.09k|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6325:9): [True: 965, False: 126]
  ------------------
 6326|  1.09k|  }
 6327|  1.27k|}
_ZN7httplib6detail6is_hexEcRi:
 5383|  12.0k|inline bool is_hex(char c, int &v) {
 5384|  12.0k|  if (is_ascii_digit(c)) {
  ------------------
  |  Branch (5384:7): [True: 7.92k, False: 4.09k]
  ------------------
 5385|  7.92k|    v = c - '0';
 5386|  7.92k|    return true;
 5387|  7.92k|  } else if ('A' <= c && c <= 'F') {
  ------------------
  |  Branch (5387:14): [True: 3.60k, False: 497]
  |  Branch (5387:26): [True: 1.56k, False: 2.03k]
  ------------------
 5388|  1.56k|    v = c - 'A' + 10;
 5389|  1.56k|    return true;
 5390|  2.53k|  } else if ('a' <= c && c <= 'f') {
  ------------------
  |  Branch (5390:14): [True: 2.03k, False: 505]
  |  Branch (5390:26): [True: 2.02k, False: 6]
  ------------------
 5391|  2.02k|    v = c - 'a' + 10;
 5392|  2.02k|    return true;
 5393|  2.02k|  }
 5394|    511|  return false;
 5395|  12.0k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE5emptyEv:
 1265|  3.13k|  bool empty() const { return entries_.empty(); }
_ZN7httplib6detail8query_ofERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9368|  6.27k|inline std::string query_of(const std::string &path) {
 9369|  6.27k|  auto fragment_pos = path.find('#');
 9370|  6.27k|  auto query_pos = path.find('?');
 9371|  6.27k|  return query_pos < fragment_pos
  ------------------
  |  Branch (9371:10): [True: 0, False: 6.27k]
  ------------------
 9372|  6.27k|             ? path.substr(query_pos + 1, fragment_pos - query_pos - 1)
 9373|  6.27k|             : std::string();
 9374|  6.27k|}
_ZN7httplib6detail18write_request_lineERNS_6StreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_:
 8885|  3.13k|                                  const std::string &path) {
 8886|       |  // Neither the method nor the request target may carry CR/LF, SP or other
 8887|       |  // control octets; otherwise a value smuggled into either splits the request
 8888|       |  // line and injects headers or a whole request.
 8889|  3.13k|  if (!fields::is_token(method)) { return -1; }
  ------------------
  |  Branch (8889:7): [True: 0, False: 3.13k]
  ------------------
 8890|  3.13k|  if (!fields::is_request_target(path)) { return -1; }
  ------------------
  |  Branch (8890:7): [True: 0, False: 3.13k]
  ------------------
 8891|       |
 8892|  3.13k|  std::string s = method;
 8893|  3.13k|  s += ' ';
 8894|  3.13k|  s += path;
 8895|  3.13k|  s += " HTTP/1.1\r\n";
 8896|  3.13k|  return strm.write(s.data(), s.size());
 8897|  3.13k|}
_ZN7httplib6detail6fields17is_request_targetERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
10595|  3.13k|inline bool is_request_target(const std::string &s) {
10596|  3.13k|  return std::all_of(s.begin(), s.end(), is_field_vchar);
10597|  3.13k|}
_ZN7httplib6detail23check_and_write_headersINSt3__18functionIFlRNS_6StreamERNS0_26insertion_ordered_multimapINS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEEEEEEEbS5_SG_T_RNS_5ErrorE:
13175|  3.13k|                                    T header_writer, Error &error) {
13176|  14.6k|  for (const auto &h : headers) {
  ------------------
  |  Branch (13176:22): [True: 14.6k, False: 3.13k]
  ------------------
13177|  14.6k|    if (!detail::fields::is_field_valid(h.first, h.second)) {
  ------------------
  |  Branch (13177:9): [True: 0, False: 14.6k]
  ------------------
13178|      0|      error = Error::InvalidHeaders;
13179|      0|      return false;
13180|      0|    }
13181|  14.6k|  }
13182|  3.13k|  if (header_writer(strm, headers) <= 0) {
  ------------------
  |  Branch (13182:7): [True: 0, False: 3.13k]
  ------------------
13183|      0|    error = Error::Write;
13184|      0|    return false;
13185|      0|  }
13186|  3.13k|  return true;
13187|  3.13k|}
_ZNK7httplib6detail12BufferStream10get_bufferEv:
12835|  3.13k|inline const std::string &BufferStream::get_buffer() const { return buffer; }
_ZN7httplib6detail10write_dataERNS_6StreamEPKcm:
 8934|  3.13k|inline bool write_data(Stream &strm, const char *d, size_t l) {
 8935|  3.13k|  size_t offset = 0;
 8936|  6.27k|  while (offset < l) {
  ------------------
  |  Branch (8936:10): [True: 3.13k, False: 3.13k]
  ------------------
 8937|  3.13k|    auto length = strm.write(d + offset, l - offset);
 8938|  3.13k|    if (length < 0) { return false; }
  ------------------
  |  Branch (8938:9): [True: 0, False: 3.13k]
  ------------------
 8939|  3.13k|    offset += static_cast<size_t>(length);
 8940|  3.13k|  }
 8941|  3.13k|  return true;
 8942|  3.13k|}
_ZNK7httplib10ClientImpl18read_response_lineERNS_6StreamERKNS_7RequestERNS_8ResponseEb:
15585|  3.13k|                                           bool skip_100_continue) const {
15586|  3.13k|  std::array<char, 2048> buf{};
15587|       |
15588|  3.13k|  detail::stream_line_reader line_reader(strm, buf.data(), buf.size());
15589|       |
15590|  3.13k|  if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (15590:7): [True: 9, False: 3.12k]
  ------------------
15591|       |
15592|  3.12k|  if (!detail::parse_status_line(line_reader.ptr(), res.version, res.status,
  ------------------
  |  Branch (15592:7): [True: 224, False: 2.90k]
  ------------------
15593|  3.12k|                                 res.reason)) {
15594|    224|    return req.method == "CONNECT";
15595|    224|  }
15596|       |
15597|       |  // Skip interim (1xx) responses along with their header fields, except a 100
15598|       |  // Continue the caller handles itself for Expect: 100-continue. 101 ends
15599|       |  // HTTP on the connection, so it is final. A server sending them without end
15600|       |  // would hold the client, so there may be only so many.
15601|  2.90k|  size_t interim_count = 0;
15602|  5.58k|  while (100 <= res.status && res.status < 200 &&
  ------------------
  |  Branch (15602:10): [True: 5.16k, False: 424]
  |  Branch (15602:31): [True: 3.03k, False: 2.13k]
  ------------------
15603|  3.03k|         res.status != StatusCode::SwitchingProtocol_101 &&
  ------------------
  |  Branch (15603:10): [True: 3.00k, False: 28]
  ------------------
15604|  3.00k|         (skip_100_continue || res.status != StatusCode::Continue_100)) {
  ------------------
  |  Branch (15604:11): [True: 3.00k, False: 0]
  |  Branch (15604:32): [True: 0, False: 0]
  ------------------
15605|  3.00k|    if (++interim_count > CPPHTTPLIB_INTERIM_RESPONSE_MAX_COUNT) {
  ------------------
  |  |  134|  3.00k|#define CPPHTTPLIB_INTERIM_RESPONSE_MAX_COUNT 100
  ------------------
  |  Branch (15605:9): [True: 1, False: 3.00k]
  ------------------
15606|      1|      return false;
15607|      1|    }
15608|  3.00k|    Headers interim_headers;
15609|  3.00k|    if (!detail::read_headers(strm, interim_headers)) { return false; }
  ------------------
  |  Branch (15609:9): [True: 238, False: 2.76k]
  ------------------
15610|  2.76k|    if (!line_reader.getline()) { return false; } // next response line
  ------------------
  |  Branch (15610:9): [True: 17, False: 2.74k]
  ------------------
15611|       |
15612|  2.74k|    if (!detail::parse_status_line(line_reader.ptr(), res.version, res.status,
  ------------------
  |  Branch (15612:9): [True: 65, False: 2.68k]
  ------------------
15613|  2.74k|                                   res.reason)) {
15614|     65|      return false;
15615|     65|    }
15616|  2.74k|  }
15617|       |
15618|  2.58k|  return true;
15619|  2.90k|}
_ZN7httplib6detail18stream_line_readerC2ERNS_6StreamEPcm:
 6420|  16.3k|    : strm_(strm), fixed_buffer_(fixed_buffer),
 6421|  16.3k|      fixed_buffer_size_(fixed_buffer_size) {}
_ZN7httplib6detail18stream_line_reader7getlineEv:
 6444|  43.7k|inline bool stream_line_reader::getline() {
 6445|  43.7k|  fixed_buffer_used_size_ = 0;
 6446|  43.7k|  growable_buffer_.clear();
 6447|       |
 6448|  43.7k|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6449|  43.7k|  char prev_byte = 0;
 6450|  43.7k|#endif
 6451|       |
 6452|  3.97M|  for (size_t i = 0;; i++) {
 6453|       |    // Fast path: whatever the stream has already buffered can be scanned for
 6454|       |    // the terminator in one pass. Asking for a byte at a time costs a virtual
 6455|       |    // call, a bounds check and a one-byte copy per character of the request.
 6456|  3.97M|    size_t buffered_size = 0;
 6457|  3.97M|    if (auto buffered = strm_.buffered_data(buffered_size)) {
  ------------------
  |  Branch (6457:14): [True: 0, False: 3.97M]
  ------------------
 6458|      0|      auto take = buffered_size;
 6459|      0|      auto terminated = false;
 6460|       |
 6461|      0|      for (size_t at = 0; at < buffered_size;) {
  ------------------
  |  Branch (6461:27): [True: 0, False: 0]
  ------------------
 6462|      0|        auto nl = static_cast<const char *>(
 6463|      0|            memchr(buffered + at, '\n', buffered_size - at));
 6464|      0|        if (!nl) { break; }
  ------------------
  |  Branch (6464:13): [True: 0, False: 0]
  ------------------
 6465|      0|        auto pos = static_cast<size_t>(nl - buffered);
 6466|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6467|       |        take = pos + 1;
 6468|       |        terminated = true;
 6469|       |        break;
 6470|       |#else
 6471|       |        // A bare LF does not end the line; keep looking for CRLF. The CR may
 6472|       |        // be the last byte of an earlier chunk, hence prev_byte.
 6473|      0|        if ((pos > 0 ? buffered[pos - 1] : prev_byte) == '\r') {
  ------------------
  |  Branch (6473:13): [True: 0, False: 0]
  |  Branch (6473:14): [True: 0, False: 0]
  ------------------
 6474|      0|          take = pos + 1;
 6475|      0|          terminated = true;
 6476|      0|          break;
 6477|      0|        }
 6478|      0|        at = pos + 1;
 6479|      0|#endif
 6480|      0|      }
 6481|       |
 6482|      0|      if (size() + take > CPPHTTPLIB_MAX_LINE_LENGTH) { return false; }
  ------------------
  |  |  227|      0|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6482:11): [True: 0, False: 0]
  ------------------
 6483|      0|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6484|      0|      prev_byte = buffered[take - 1];
 6485|      0|#endif
 6486|      0|      append(buffered, take);
 6487|      0|      strm_.consume_buffered(take);
 6488|      0|      i += take;
 6489|      0|      if (terminated) { return true; }
  ------------------
  |  Branch (6489:11): [True: 0, False: 0]
  ------------------
 6490|      0|      continue;
 6491|      0|    }
 6492|       |
 6493|  3.97M|    if (size() >= CPPHTTPLIB_MAX_LINE_LENGTH) {
  ------------------
  |  |  227|  3.97M|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6493:9): [True: 3, False: 3.97M]
  ------------------
 6494|       |      // Treat exceptionally long lines as an error to
 6495|       |      // prevent infinite loops/memory exhaustion
 6496|      3|      return false;
 6497|      3|    }
 6498|  3.97M|    char byte;
 6499|  3.97M|    auto n = strm_.read(&byte, 1);
 6500|       |
 6501|  3.97M|    if (n < 0) {
  ------------------
  |  Branch (6501:9): [True: 0, False: 3.97M]
  ------------------
 6502|      0|      return false;
 6503|  3.97M|    } else if (n == 0) {
  ------------------
  |  Branch (6503:16): [True: 1.25k, False: 3.97M]
  ------------------
 6504|  1.25k|      if (i == 0) {
  ------------------
  |  Branch (6504:11): [True: 446, False: 805]
  ------------------
 6505|    446|        return false;
 6506|    805|      } else {
 6507|    805|        break;
 6508|    805|      }
 6509|  1.25k|    }
 6510|       |
 6511|  3.97M|    append(byte);
 6512|       |
 6513|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6514|       |    if (byte == '\n') { break; }
 6515|       |#else
 6516|  3.97M|    if (prev_byte == '\r' && byte == '\n') { break; }
  ------------------
  |  Branch (6516:9): [True: 42.9k, False: 3.93M]
  |  Branch (6516:30): [True: 42.5k, False: 399]
  ------------------
 6517|  3.93M|    prev_byte = byte;
 6518|  3.93M|#endif
 6519|  3.93M|  }
 6520|       |
 6521|  43.3k|  return true;
 6522|  43.7k|}
_ZNK7httplib6detail18stream_line_reader4sizeEv:
 6431|  4.12M|inline size_t stream_line_reader::size() const {
 6432|  4.12M|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6432:7): [True: 2.34M, False: 1.78M]
  ------------------
 6433|  2.34M|    return fixed_buffer_used_size_;
 6434|  2.34M|  } else {
 6435|  1.78M|    return growable_buffer_.size();
 6436|  1.78M|  }
 6437|  4.12M|}
_ZN7httplib6detail18stream_line_reader6appendEPKcm:
 6526|  3.97M|inline void stream_line_reader::append(const char *data, size_t size) {
 6527|       |  // Once the line has outgrown the fixed buffer everything must keep going to
 6528|       |  // the growable one, even if a later chunk would have fit. Without the
 6529|       |  // emptiness check a short append after a long one would land in the fixed
 6530|       |  // buffer, which ptr() and size() no longer look at, and be lost.
 6531|  3.97M|  if (growable_buffer_.empty() &&
  ------------------
  |  Branch (6531:7): [True: 2.19M, False: 1.77M]
  ------------------
 6532|  2.19M|      fixed_buffer_used_size_ + size < fixed_buffer_size_) {
  ------------------
  |  Branch (6532:7): [True: 2.19M, False: 883]
  ------------------
 6533|  2.19M|    memcpy(fixed_buffer_ + fixed_buffer_used_size_, data, size);
 6534|  2.19M|    fixed_buffer_used_size_ += size;
 6535|  2.19M|    fixed_buffer_[fixed_buffer_used_size_] = '\0';
 6536|  2.19M|  } else {
 6537|       |    // Unlike the per-character overload, this can be the very first append of
 6538|       |    // the line, so the fixed buffer may hold nothing and carry no terminator
 6539|       |    // yet. assign() takes an explicit length and does not need one.
 6540|  1.78M|    if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6540:9): [True: 883, False: 1.77M]
  ------------------
 6541|    883|      growable_buffer_.assign(fixed_buffer_, fixed_buffer_used_size_);
 6542|    883|    }
 6543|  1.78M|    growable_buffer_.append(data, size);
 6544|  1.78M|  }
 6545|  3.97M|}
_ZN7httplib6detail18stream_line_reader6appendEc:
 6524|  3.97M|inline void stream_line_reader::append(char c) { append(&c, 1); }
_ZN7httplib6detail17parse_status_lineEPKcRNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERiSA_:
 8493|  5.87k|                              int &status, std::string &reason) {
 8494|  5.87k|  if (std::strncmp(line, "HTTP/1.", 7) != 0 ||
  ------------------
  |  Branch (8494:7): [True: 137, False: 5.74k]
  ------------------
 8495|  5.74k|      (line[7] != '0' && line[7] != '1') || line[8] != ' ' ||
  ------------------
  |  Branch (8495:8): [True: 3.71k, False: 2.03k]
  |  Branch (8495:26): [True: 25, False: 3.68k]
  |  Branch (8495:45): [True: 33, False: 5.68k]
  ------------------
 8496|  5.68k|      !is_ascii_digit(line[9]) || !is_ascii_digit(line[10]) ||
  ------------------
  |  Branch (8496:7): [True: 13, False: 5.67k]
  |  Branch (8496:35): [True: 7, False: 5.66k]
  ------------------
 8497|  5.66k|      !is_ascii_digit(line[11])) {
  ------------------
  |  Branch (8497:7): [True: 3, False: 5.66k]
  ------------------
 8498|    218|    return false;
 8499|    218|  }
 8500|       |
 8501|  5.66k|  auto p = line + 12;
 8502|  5.66k|  auto reason_begin = p;
 8503|  5.66k|  if (*p == ' ') {
  ------------------
  |  Branch (8503:7): [True: 1.25k, False: 4.40k]
  ------------------
 8504|  1.25k|    reason_begin = ++p;
 8505|  1.25k|    p += std::strcspn(p, "\r\n");
 8506|  1.25k|  }
 8507|  5.66k|  auto reason_end = p;
 8508|       |
 8509|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 8510|       |  if (*p == '\r') { p++; }
 8511|       |#else
 8512|  5.66k|  if (*p++ != '\r') { return false; }
  ------------------
  |  Branch (8512:7): [True: 51, False: 5.60k]
  ------------------
 8513|  5.60k|#endif
 8514|  5.60k|  if (*p++ != '\n' || *p != '\0') { return false; }
  ------------------
  |  Branch (8514:7): [True: 20, False: 5.58k]
  |  Branch (8514:23): [True: 0, False: 5.58k]
  ------------------
 8515|       |
 8516|  5.58k|  version.assign(line, 8);
 8517|  5.58k|  status = (line[9] - '0') * 100 + (line[10] - '0') * 10 + (line[11] - '0');
 8518|  5.58k|  reason.assign(reason_begin, reason_end);
 8519|  5.58k|  return true;
 8520|  5.60k|}
_ZNK7httplib6detail18stream_line_reader3ptrEv:
 6423|   101k|inline const char *stream_line_reader::ptr() const {
 6424|   101k|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6424:7): [True: 99.1k, False: 2.56k]
  ------------------
 6425|  99.1k|    return fixed_buffer_;
 6426|  99.1k|  } else {
 6427|  2.56k|    return growable_buffer_.data();
 6428|  2.56k|  }
 6429|   101k|}
_ZN7httplib10ClientImpl18write_request_bodyERNS_6StreamERNS_7RequestERNS_5ErrorE:
16655|  3.13k|                                           Error &error) {
16656|  3.13k|  if (req.body.empty()) {
  ------------------
  |  Branch (16656:7): [True: 3.13k, False: 0]
  ------------------
16657|  3.13k|    return write_content_with_provider(strm, req, error);
16658|  3.13k|  }
16659|       |
16660|      0|  if (req.upload_progress) {
  ------------------
  |  Branch (16660:7): [True: 0, False: 0]
  ------------------
16661|      0|    auto body_size = req.body.size();
16662|      0|    size_t written = 0;
16663|      0|    auto data = req.body.data();
16664|       |
16665|      0|    while (written < body_size) {
  ------------------
  |  Branch (16665:12): [True: 0, False: 0]
  ------------------
16666|      0|      size_t to_write = (std::min)(CPPHTTPLIB_SEND_BUFSIZ, body_size - written);
  ------------------
  |  |  192|      0|#define CPPHTTPLIB_SEND_BUFSIZ size_t(16384u)
  ------------------
16667|      0|      if (!detail::write_data(strm, data + written, to_write)) {
  ------------------
  |  Branch (16667:11): [True: 0, False: 0]
  ------------------
16668|      0|        error = Error::Write;
16669|      0|        return false;
16670|      0|      }
16671|      0|      written += to_write;
16672|       |
16673|      0|      if (!req.upload_progress(written, body_size)) {
  ------------------
  |  Branch (16673:11): [True: 0, False: 0]
  ------------------
16674|      0|        error = Error::Canceled;
16675|      0|        return false;
16676|      0|      }
16677|      0|    }
16678|      0|  } else {
16679|      0|    if (!detail::write_data(strm, req.body.data(), req.body.size())) {
  ------------------
  |  Branch (16679:9): [True: 0, False: 0]
  ------------------
16680|      0|      error = Error::Write;
16681|      0|      return false;
16682|      0|    }
16683|      0|  }
16684|       |
16685|      0|  return true;
16686|      0|}
_ZNK7httplib10ClientImpl27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_5ErrorE:
16480|  3.13k|                                                    Error &error) const {
16481|  3.13k|  auto is_shutting_down = []() { return false; };
16482|       |
16483|  3.13k|  if (req.is_chunked_content_provider_) {
  ------------------
  |  Branch (16483:7): [True: 0, False: 3.13k]
  ------------------
16484|      0|    auto compressor = compress_ ? detail::create_compressor().first
  ------------------
  |  Branch (16484:23): [True: 0, False: 0]
  ------------------
16485|      0|                                : std::unique_ptr<detail::compressor>();
16486|      0|    if (!compressor) {
  ------------------
  |  Branch (16486:9): [True: 0, False: 0]
  ------------------
16487|      0|      compressor = detail::make_unique<detail::nocompressor>();
16488|      0|    }
16489|       |
16490|      0|    return detail::write_content_chunked(strm, req.content_provider_,
16491|      0|                                         is_shutting_down, *compressor, error);
16492|  3.13k|  } else {
16493|  3.13k|    return detail::write_content_with_progress(
16494|  3.13k|        strm, req.content_provider_, 0, req.content_length_, is_shutting_down,
16495|  3.13k|        req.upload_progress, error);
16496|  3.13k|  }
16497|  3.13k|}
_ZN7httplib8DataSinkC2Ev:
 1553|  3.13k|  DataSink() : os(&sb_), sb_(*this) {}
_ZN7httplib8DataSink19data_sink_streambufC2ERS0_:
 1576|  3.13k|    explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}
_ZN7httplib6detail27write_content_with_progressIZNKS_10ClientImpl27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_5ErrorEEUlvE_EEbS4_RKNSt3__18functionIFbmmRNS_8DataSinkEEEEmmT_RKNSC_IFbmmEEES9_:
 8950|  3.13k|                                        Error &error) {
 8951|  3.13k|  size_t end_offset = offset + length;
 8952|  3.13k|  size_t start_offset = offset;
 8953|  3.13k|  auto ok = true;
 8954|  3.13k|  auto finished = false;
 8955|  3.13k|  DataSink data_sink;
 8956|       |
 8957|  3.13k|  data_sink.write = [&](const char *d, size_t l) -> bool {
 8958|  3.13k|    if (ok) {
 8959|       |      // Bytes past `length` would follow the framed body, where the peer reads
 8960|       |      // them as the next message. Write only what fits and fail the rest.
 8961|  3.13k|      if (l > end_offset - offset) {
 8962|  3.13k|        l = end_offset - offset;
 8963|  3.13k|        ok = false;
 8964|  3.13k|      }
 8965|  3.13k|      if (write_data(strm, d, l)) {
 8966|  3.13k|        offset += l;
 8967|       |
 8968|  3.13k|        if (upload_progress && length > 0) {
 8969|  3.13k|          size_t current_written = offset - start_offset;
 8970|  3.13k|          if (!upload_progress(current_written, length)) {
 8971|  3.13k|            ok = false;
 8972|  3.13k|            return false;
 8973|  3.13k|          }
 8974|  3.13k|        }
 8975|  3.13k|      } else {
 8976|  3.13k|        ok = false;
 8977|  3.13k|      }
 8978|  3.13k|    }
 8979|  3.13k|    return ok;
 8980|  3.13k|  };
 8981|       |
 8982|  3.13k|  data_sink.is_writable = [&]() -> bool { return strm.is_peer_alive(); };
 8983|       |
 8984|       |  // The body is framed by `length`, so a provider that reports itself done
 8985|       |  // early has truncated it. Record that and let the short-body check below
 8986|       |  // fail the write, rather than calling the provider again forever.
 8987|  3.13k|  data_sink.done = [&]() { finished = true; };
 8988|       |
 8989|  3.13k|  while (offset < end_offset && !finished && !is_shutting_down()) {
  ------------------
  |  Branch (8989:10): [True: 0, False: 3.13k]
  |  Branch (8989:33): [True: 0, False: 0]
  |  Branch (8989:46): [True: 0, False: 0]
  ------------------
 8990|      0|    auto last_offset = offset;
 8991|       |
 8992|      0|    if (!strm.wait_writable() || !strm.is_peer_alive()) {
  ------------------
  |  Branch (8992:9): [True: 0, False: 0]
  |  Branch (8992:34): [True: 0, False: 0]
  ------------------
 8993|      0|      error = Error::Write;
 8994|      0|      return false;
 8995|      0|    } else if (!content_provider(offset, end_offset - offset, data_sink)) {
  ------------------
  |  Branch (8995:16): [True: 0, False: 0]
  ------------------
 8996|      0|      error = Error::Canceled;
 8997|      0|      return false;
 8998|      0|    } else if (!ok) {
  ------------------
  |  Branch (8998:16): [True: 0, False: 0]
  ------------------
 8999|      0|      error = Error::Write;
 9000|      0|      return false;
 9001|      0|    }
 9002|       |
 9003|       |    // A provider that reports success without writing anything and without
 9004|       |    // reporting itself done gets handed the same offset and length again on
 9005|       |    // the next pass, so it would spin here for as long as the peer stays
 9006|       |    // connected. Treat making no progress as a short body, like done() early.
 9007|      0|    if (!finished && offset == last_offset) {
  ------------------
  |  Branch (9007:9): [True: 0, False: 0]
  |  Branch (9007:22): [True: 0, False: 0]
  ------------------
 9008|      0|      error = Error::Write;
 9009|      0|      return false;
 9010|      0|    }
 9011|      0|  }
 9012|       |
 9013|  3.13k|  if (offset < end_offset) { // done() called early, or is_shutting_down()
  ------------------
  |  Branch (9013:7): [True: 0, False: 3.13k]
  ------------------
 9014|      0|    error = Error::Write;
 9015|      0|    return false;
 9016|      0|  }
 9017|       |
 9018|  3.13k|  error = Error::Success;
 9019|  3.13k|  return true;
 9020|  3.13k|}
_ZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 8434|  5.58k|inline bool read_headers(Stream &strm, Headers &headers) {
 8435|  5.58k|  const auto bufsiz = 2048;
 8436|  5.58k|  char buf[bufsiz];
 8437|  5.58k|  stream_line_reader line_reader(strm, buf, bufsiz);
 8438|       |
 8439|  5.58k|  size_t header_count = 0;
 8440|       |
 8441|  28.8k|  for (;;) {
 8442|  28.8k|    if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (8442:9): [True: 340, False: 28.5k]
  ------------------
 8443|       |
 8444|       |    // Check if the line ends with CRLF.
 8445|  28.5k|    auto line_terminator_len = 2;
 8446|  28.5k|    if (line_reader.end_with_crlf()) {
  ------------------
  |  Branch (8446:9): [True: 28.4k, False: 110]
  ------------------
 8447|       |      // Blank line indicates end of headers.
 8448|  28.4k|      if (line_reader.size() == 2) { break; }
  ------------------
  |  Branch (8448:11): [True: 4.82k, False: 23.6k]
  ------------------
 8449|  28.4k|    } else {
 8450|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 8451|       |      // Blank line indicates end of headers.
 8452|       |      if (line_reader.size() == 1) { break; }
 8453|       |      line_terminator_len = 1;
 8454|       |#else
 8455|    110|      continue; // Skip invalid line.
 8456|    110|#endif
 8457|    110|    }
 8458|       |
 8459|  23.6k|    if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
  ------------------
  |  |  122|  23.6k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (8459:9): [True: 4, False: 23.6k]
  ------------------
 8460|       |
 8461|       |    // Check header count limit
 8462|  23.6k|    if (header_count >= CPPHTTPLIB_HEADER_MAX_COUNT) { return false; }
  ------------------
  |  |  126|  23.6k|#define CPPHTTPLIB_HEADER_MAX_COUNT 100
  ------------------
  |  Branch (8462:9): [True: 1, False: 23.6k]
  ------------------
 8463|       |
 8464|       |    // Exclude line terminator
 8465|  23.6k|    auto end = line_reader.ptr() + line_reader.size() - line_terminator_len;
 8466|       |
 8467|  23.6k|    if (!parse_header(line_reader.ptr(), end,
  ------------------
  |  Branch (8467:9): [True: 422, False: 23.1k]
  ------------------
 8468|  23.6k|                      [&](const std::string &key, const std::string &val) {
 8469|  23.6k|                        headers.emplace(key, val);
 8470|  23.6k|                      })) {
 8471|    422|      return false;
 8472|    422|    }
 8473|       |
 8474|  23.1k|    header_count++;
 8475|  23.1k|  }
 8476|       |
 8477|       |  // RFC 9110 Section 8.6: Reject requests with multiple Content-Length
 8478|       |  // headers that have different values to prevent request smuggling.
 8479|  4.82k|  auto cl_range = headers.equal_range("Content-Length");
 8480|  4.82k|  if (cl_range.first != cl_range.second) {
  ------------------
  |  Branch (8480:7): [True: 1.00k, False: 3.81k]
  ------------------
 8481|  1.00k|    const auto &first_val = cl_range.first->second;
 8482|  2.88k|    for (auto it = std::next(cl_range.first); it != cl_range.second; ++it) {
  ------------------
  |  Branch (8482:47): [True: 2.05k, False: 827]
  ------------------
 8483|  2.05k|      if (it->second != first_val) { return false; }
  ------------------
  |  Branch (8483:11): [True: 182, False: 1.87k]
  ------------------
 8484|  2.05k|    }
 8485|  1.00k|  }
 8486|       |
 8487|  4.63k|  return true;
 8488|  4.82k|}
_ZNK7httplib6detail18stream_line_reader13end_with_crlfEv:
 6439|  32.5k|inline bool stream_line_reader::end_with_crlf() const {
 6440|  32.5k|  auto end = ptr() + size();
 6441|  32.5k|  return size() >= 2 && end[-2] == '\r' && end[-1] == '\n';
  ------------------
  |  Branch (6441:10): [True: 32.4k, False: 95]
  |  Branch (6441:25): [True: 32.2k, False: 268]
  |  Branch (6441:44): [True: 32.2k, False: 21]
  ------------------
 6442|  32.5k|}
_ZN7httplib6detail12parse_headerIZNS0_12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS0_11case_ignore8equal_toEEEEUlRKSB_SH_E_EEbPKcSK_T_:
 6102|  23.6k|inline bool parse_header(const char *beg, const char *end, T fn) {
 6103|       |  // Skip trailing spaces and tabs.
 6104|  24.1k|  while (beg < end && is_space_or_tab(end[-1])) {
  ------------------
  |  Branch (6104:10): [True: 24.1k, False: 16]
  |  Branch (6104:23): [True: 584, False: 23.5k]
  ------------------
 6105|    584|    end--;
 6106|    584|  }
 6107|       |
 6108|  23.6k|  auto p = beg;
 6109|   266k|  while (p < end && *p != ':') {
  ------------------
  |  Branch (6109:10): [True: 265k, False: 312]
  |  Branch (6109:21): [True: 242k, False: 23.2k]
  ------------------
 6110|   242k|    p++;
 6111|   242k|  }
 6112|       |
 6113|  23.6k|  auto name = std::string(beg, p);
 6114|  23.6k|  if (!detail::fields::is_field_name(name)) { return false; }
  ------------------
  |  Branch (6114:7): [True: 142, False: 23.4k]
  ------------------
 6115|       |
 6116|  23.4k|  if (p == end) { return false; }
  ------------------
  |  Branch (6116:7): [True: 195, False: 23.2k]
  ------------------
 6117|       |
 6118|  23.2k|  auto key_end = p;
 6119|       |
 6120|  23.2k|  if (*p++ != ':') { return false; }
  ------------------
  |  Branch (6120:7): [True: 0, False: 23.2k]
  ------------------
 6121|       |
 6122|  23.7k|  while (p < end && is_space_or_tab(*p)) {
  ------------------
  |  Branch (6122:10): [True: 9.29k, False: 14.4k]
  |  Branch (6122:21): [True: 428, False: 8.86k]
  ------------------
 6123|    428|    p++;
 6124|    428|  }
 6125|       |
 6126|  23.2k|  if (p <= end) {
  ------------------
  |  Branch (6126:7): [True: 23.2k, False: 0]
  ------------------
 6127|  23.2k|    auto key_len = key_end - beg;
 6128|  23.2k|    if (!key_len) { return false; }
  ------------------
  |  Branch (6128:9): [True: 0, False: 23.2k]
  ------------------
 6129|       |
 6130|  23.2k|    auto key = std::string(beg, key_end);
 6131|  23.2k|    auto val = std::string(p, end);
 6132|       |
 6133|  23.2k|    if (!detail::fields::is_field_value(val)) { return false; }
  ------------------
  |  Branch (6133:9): [True: 85, False: 23.1k]
  ------------------
 6134|       |
 6135|       |    // RFC 9110 §5.5: header field values are opaque octets and MUST NOT be
 6136|       |    // percent-decoded by the recipient. Applications that need to interpret a
 6137|       |    // value as a URI component should call httplib::decode_uri_component()
 6138|       |    // (or decode_path_component()) explicitly.
 6139|  23.1k|    fn(key, val);
 6140|       |
 6141|  23.1k|    return true;
 6142|  23.2k|  }
 6143|       |
 6144|      0|  return false;
 6145|  23.2k|}
_ZZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEEENKUlRKSA_SG_E_clESG_SG_:
 8468|  23.1k|                      [&](const std::string &key, const std::string &val) {
 8469|  23.1k|                        headers.emplace(key, val);
 8470|  23.1k|                      })) {
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1310|  4.82k|  std::pair<iterator, iterator> equal_range(const std::string &key) {
 1311|  4.82k|    auto i = index_of(key);
 1312|  4.82k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1312:12): [True: 3.81k, False: 1.00k]
  ------------------
 1313|  4.82k|                       : std::make_pair(make_iter(i, i), end());
 1314|  4.82k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEptEv:
 1184|  3.06k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail30has_conflicting_content_lengthERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 8758|  1.85k|inline bool has_conflicting_content_length(const Headers &headers) {
 8759|       |  // RFC 9112 §6.3: a message carrying both Transfer-Encoding and a non-zero
 8760|       |  // Content-Length is framed ambiguously. The body readers here delimit it by
 8761|       |  // the transfer coding and drop Content-Length, while an intermediary may do
 8762|       |  // the reverse, so the two disagree on where the body ends and a reused
 8763|       |  // connection is desynchronised (request/response smuggling). Content-Length:
 8764|       |  // 0 is tolerated for compatibility with existing peers.
 8765|  1.85k|  return has_header(headers, "Transfer-Encoding") &&
  ------------------
  |  Branch (8765:10): [True: 1.05k, False: 795]
  ------------------
 8766|  1.05k|         get_header_value_u64(headers, "Content-Length", 0, 0) > 0;
  ------------------
  |  Branch (8766:10): [True: 114, False: 943]
  ------------------
 8767|  1.85k|}
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mm:
 3603|  1.61k|                                   size_t id) {
 3604|  1.61k|  auto dummy = false;
 3605|  1.61k|  return get_header_value_u64(headers, key, def, id, dummy);
 3606|  1.61k|}
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mmRb:
 3576|  2.09k|                                   size_t id, bool &is_invalid_value) {
 3577|  2.09k|  is_invalid_value = false;
 3578|  2.09k|  auto rng = headers.equal_range(key);
 3579|  2.09k|  auto it = bounded_next(rng.first, id, rng.second);
 3580|  2.09k|  if (it != rng.second) {
  ------------------
  |  Branch (3580:7): [True: 1.19k, False: 895]
  ------------------
 3581|  1.19k|    if (is_numeric(it->second)) {
  ------------------
  |  Branch (3581:9): [True: 982, False: 215]
  ------------------
 3582|       |      // Parse at size_t width so an out-of-range Content-Length is reported
 3583|       |      // rather than silently saturated/truncated (a value above 2^32 would
 3584|       |      // otherwise wrap to a small framing length on 32-bit builds). Flag it
 3585|       |      // and return SIZE_MAX so the existing oversized-value guards reject it.
 3586|    982|      size_t val = 0;
 3587|    982|      const auto &s = it->second;
 3588|    982|      auto r = from_chars(s.data(), s.data() + s.size(), val);
 3589|    982|      if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (3589:11): [True: 65, False: 917]
  ------------------
 3590|     65|        is_invalid_value = true;
 3591|     65|        return (std::numeric_limits<size_t>::max)();
 3592|     65|      }
 3593|    917|      return val;
 3594|    982|    } else {
 3595|    215|      is_invalid_value = true;
 3596|    215|    }
 3597|  1.19k|  }
 3598|  1.11k|  return def;
 3599|  2.09k|}
_ZN7httplib6detail12bounded_nextINS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS3_4pairIS9_S9_EEEEEET_SI_mSI_:
 3567|  2.09k|template <typename It> inline It bounded_next(It first, size_t n, It last) {
 3568|  2.09k|  for (; n > 0 && first != last; --n) {
  ------------------
  |  Branch (3568:10): [True: 0, False: 2.09k]
  |  Branch (3568:19): [True: 0, False: 0]
  ------------------
 3569|      0|    ++first;
 3570|      0|  }
 3571|  2.09k|  return first;
 3572|  2.09k|}
_ZN7httplib6detail10is_numericERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 3562|  1.19k|inline bool is_numeric(const std::string &str) {
 3563|  1.19k|  return !str.empty() && std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
  ------------------
  |  Branch (3563:10): [True: 1.06k, False: 137]
  |  Branch (3563:26): [True: 982, False: 78]
  ------------------
 3564|  1.19k|}
_ZN7httplib6detail10from_charsImEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  763|    982|                                       T &value, int base = 10) {
  764|    982|  value = 0;
  765|    982|  const char *p = first;
  766|    982|  bool negative = false;
  767|       |
  768|    982|  if (p != last && *p == '-') {
  ------------------
  |  Branch (768:7): [True: 982, False: 0]
  |  Branch (768:20): [True: 0, False: 982]
  ------------------
  769|      0|    negative = true;
  770|      0|    ++p;
  771|      0|  }
  772|    982|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (772:7): [True: 0, False: 982]
  ------------------
  773|       |
  774|    982|  auto radix = static_cast<T>(base);
  775|    982|  T result = 0;
  776|  15.7k|  for (; p != last; ++p) {
  ------------------
  |  Branch (776:10): [True: 14.8k, False: 917]
  ------------------
  777|  14.8k|    char c = *p;
  778|  14.8k|    int digit = -1;
  779|  14.8k|    if (is_ascii_digit(c)) {
  ------------------
  |  Branch (779:9): [True: 14.8k, False: 0]
  ------------------
  780|  14.8k|      digit = c - '0';
  781|  14.8k|    } else if ('a' <= c && c <= 'z') {
  ------------------
  |  Branch (781:16): [True: 0, False: 0]
  |  Branch (781:28): [True: 0, False: 0]
  ------------------
  782|      0|      digit = c - 'a' + 10;
  783|      0|    } else if ('A' <= c && c <= 'Z') {
  ------------------
  |  Branch (783:16): [True: 0, False: 0]
  |  Branch (783:28): [True: 0, False: 0]
  ------------------
  784|      0|      digit = c - 'A' + 10;
  785|      0|    } else {
  786|      0|      break;
  787|      0|    }
  788|       |
  789|  14.8k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (789:9): [True: 0, False: 14.8k]
  |  Branch (789:22): [True: 0, False: 14.8k]
  ------------------
  790|  14.8k|    auto d = static_cast<T>(digit);
  791|  14.8k|    if (result > ((std::numeric_limits<T>::max)() - d) / radix) {
  ------------------
  |  Branch (791:9): [True: 65, False: 14.7k]
  ------------------
  792|     65|      return {p, std::errc::result_out_of_range};
  793|     65|    }
  794|  14.7k|    result = result * radix + d;
  795|  14.7k|  }
  796|       |
  797|    917|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (797:7): [True: 0, False: 917]
  |  Branch (797:22): [True: 0, False: 917]
  |  Branch (797:34): [True: 0, False: 0]
  ------------------
  798|      0|    return {first, std::errc::invalid_argument};
  799|      0|  }
  800|       |
  801|    917|  value = negative ? T(0) - result : result;
  ------------------
  |  Branch (801:11): [True: 0, False: 917]
  ------------------
  802|    917|  return {p, std::errc{}};
  803|    917|}
_ZN7httplib6detail28has_faulty_transfer_encodingINS_8ResponseEEEbRKT_:
 8753|  1.73k|template <typename T> inline bool has_faulty_transfer_encoding(const T &msg) {
 8754|  1.73k|  return msg.has_header("Transfer-Encoding") &&
  ------------------
  |  Branch (8754:10): [True: 943, False: 795]
  ------------------
 8755|    943|         (msg.has_header("Content-Length") || msg.version == "HTTP/1.0");
  ------------------
  |  Branch (8755:11): [True: 48, False: 895]
  |  Branch (8755:47): [True: 463, False: 432]
  ------------------
 8756|  1.73k|}
_ZZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorEENKUlPKcmmmE0_clESA_mmm:
16982|   126k|                      size_t /*len*/) {
16983|   126k|                    assert(res.body.size() + n <= res.body.max_size());
  ------------------
  |  Branch (16983:21): [True: 126k, False: 0]
  ------------------
16984|   126k|                    if (payload_max_length_ > 0 &&
  ------------------
  |  Branch (16984:25): [True: 126k, False: 0]
  ------------------
16985|   126k|                        (res.body.size() >= payload_max_length_ ||
  ------------------
  |  Branch (16985:26): [True: 0, False: 126k]
  ------------------
16986|   126k|                         n > payload_max_length_ - res.body.size())) {
  ------------------
  |  Branch (16986:26): [True: 0, False: 126k]
  ------------------
16987|      0|                      return false;
16988|      0|                    }
16989|   126k|                    res.body.append(buf, n);
16990|   126k|                    return true;
16991|   126k|                  });
_ZNK7httplib8Response10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12265|  4.43k|inline bool Response::has_header(const std::string &key) const {
12266|  4.43k|  return headers.find(key) != headers.end();
12267|  4.43k|}
_ZNK7httplib8Response20get_header_value_u64ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEmm:
12261|    561|                                             size_t id) const {
12262|    561|  return detail::get_header_value_u64(headers, key, def, id);
12263|    561|}
_ZN7httplib6detail12read_contentINS_8ResponseEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEb:
 8827|  1.67k|                  ContentReceiverWithProgress receiver, bool decompress) {
 8828|  1.67k|  bool exceed_payload_max_length = false;
 8829|  1.67k|  return prepare_content_receiver(
 8830|  1.67k|      x, status, std::move(receiver), decompress, payload_max_length,
 8831|  1.67k|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 8832|  1.67k|        auto ret = true;
 8833|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 8834|       |        // wrapper in prepare_content_receiver when the decompressed payload
 8835|       |        // size exceeds the limit.
 8836|       |
 8837|  1.67k|        if (is_chunked_transfer_encoding(x.headers)) {
 8838|  1.67k|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 8839|  1.67k|          if (result == ReadContentResult::Success) {
 8840|  1.67k|            ret = true;
 8841|  1.67k|          } else if (result == ReadContentResult::PayloadTooLarge) {
 8842|  1.67k|            exceed_payload_max_length = true;
 8843|  1.67k|            ret = false;
 8844|  1.67k|          } else {
 8845|  1.67k|            ret = false;
 8846|  1.67k|          }
 8847|  1.67k|        } else if (!has_header(x.headers, "Content-Length")) {
 8848|  1.67k|          auto result =
 8849|  1.67k|              read_content_without_length(strm, payload_max_length, out);
 8850|  1.67k|          if (result == ReadContentResult::Success) {
 8851|  1.67k|            ret = true;
 8852|  1.67k|          } else if (result == ReadContentResult::PayloadTooLarge) {
 8853|  1.67k|            exceed_payload_max_length = true;
 8854|  1.67k|            ret = false;
 8855|  1.67k|          } else {
 8856|  1.67k|            ret = false;
 8857|  1.67k|          }
 8858|  1.67k|        } else {
 8859|  1.67k|          auto is_invalid_value = false;
 8860|  1.67k|          auto len = get_header_value_u64(x.headers, "Content-Length",
 8861|  1.67k|                                          (std::numeric_limits<size_t>::max)(),
 8862|  1.67k|                                          0, is_invalid_value);
 8863|       |
 8864|  1.67k|          if (is_invalid_value) {
 8865|  1.67k|            ret = false;
 8866|  1.67k|          } else if (len > 0) {
 8867|  1.67k|            auto result = read_content_with_length(
 8868|  1.67k|                strm, len, std::move(progress), out, payload_max_length);
 8869|  1.67k|            ret = (result == ReadContentResult::Success);
 8870|  1.67k|            if (result == ReadContentResult::PayloadTooLarge) {
 8871|  1.67k|              exceed_payload_max_length = true;
 8872|  1.67k|            }
 8873|  1.67k|          }
 8874|  1.67k|        }
 8875|       |
 8876|  1.67k|        if (!ret) {
 8877|  1.67k|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
 8878|  1.67k|                                             : StatusCode::BadRequest_400;
 8879|  1.67k|        }
 8880|  1.67k|        return ret;
 8881|  1.67k|      });
 8882|  1.67k|}
_ZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_:
 8773|  1.67k|                              bool &exceed_payload_max_length, U callback) {
 8774|  1.67k|  if (decompress) {
  ------------------
  |  Branch (8774:7): [True: 1.67k, False: 0]
  ------------------
 8775|  1.67k|    auto encoding = get_combined_header_value(x.headers, "Content-Encoding");
 8776|  1.67k|    std::unique_ptr<decompressor> decompressor;
 8777|       |
 8778|  1.67k|    if (!encoding.empty()) {
  ------------------
  |  Branch (8778:9): [True: 241, False: 1.43k]
  ------------------
 8779|       |      // A coding we know about but were not built with is an error. An
 8780|       |      // unrecognized coding (including "identity") is left alone and the
 8781|       |      // payload is passed through as-is, since some servers misuse the header,
 8782|       |      // e.g. by sending a character set such as "Content-Encoding: UTF-8".
 8783|    241|      decompressor = detail::create_decompressor(encoding);
 8784|    241|      if (!decompressor && detail::is_known_content_encoding(encoding)) {
  ------------------
  |  Branch (8784:11): [True: 93, False: 148]
  |  Branch (8784:28): [True: 2, False: 91]
  ------------------
 8785|      2|        status = StatusCode::UnsupportedMediaType_415;
 8786|      2|        return false;
 8787|      2|      }
 8788|    241|    }
 8789|       |
 8790|  1.66k|    if (decompressor) {
  ------------------
  |  Branch (8790:9): [True: 148, False: 1.52k]
  ------------------
 8791|    148|      if (decompressor->is_valid()) {
  ------------------
  |  Branch (8791:11): [True: 148, False: 0]
  ------------------
 8792|    148|        size_t decompressed_size = 0;
 8793|    148|        ContentReceiverWithProgress out = [&](const char *buf, size_t n,
 8794|    148|                                              size_t off, size_t len) {
 8795|    148|          return decompressor->decompress(
 8796|    148|              buf, n, [&](const char *buf2, size_t n2) {
 8797|       |                // Guard against zip-bomb: check
 8798|       |                // decompressed size against limit.
 8799|    148|                if (payload_max_length > 0 &&
 8800|    148|                    (decompressed_size >= payload_max_length ||
 8801|    148|                     n2 > payload_max_length - decompressed_size)) {
 8802|    148|                  exceed_payload_max_length = true;
 8803|    148|                  return false;
 8804|    148|                }
 8805|    148|                decompressed_size += n2;
 8806|    148|                return receiver(buf2, n2, off, len);
 8807|    148|              });
 8808|    148|        };
 8809|    148|        return callback(std::move(out));
 8810|    148|      } else {
 8811|      0|        status = StatusCode::InternalServerError_500;
 8812|      0|        return false;
 8813|      0|      }
 8814|    148|    }
 8815|  1.66k|  }
 8816|       |
 8817|  1.52k|  ContentReceiverWithProgress out = [&](const char *buf, size_t n, size_t off,
 8818|  1.52k|                                        size_t len) {
 8819|  1.52k|    return receiver(buf, n, off, len);
 8820|  1.52k|  };
 8821|  1.52k|  return callback(std::move(out));
 8822|  1.67k|}
_ZN7httplib6detail25get_combined_header_valueERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 8387|  1.81k|                                             const std::string &key) {
 8388|  1.81k|  std::string combined;
 8389|  1.81k|  auto rng = headers.equal_range(key);
 8390|  3.10k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (8390:29): [True: 1.28k, False: 1.81k]
  ------------------
 8391|       |    // RFC 9110 Section 5.6.1.2: a recipient has to parse and ignore empty list
 8392|       |    // elements, so an empty field line must not contribute a bare comma to the
 8393|       |    // combined value.
 8394|  1.28k|    if (it->second.empty()) { continue; }
  ------------------
  |  Branch (8394:9): [True: 114, False: 1.17k]
  ------------------
 8395|  1.17k|    if (!combined.empty()) { combined += ", "; }
  ------------------
  |  Branch (8395:9): [True: 930, False: 241]
  ------------------
 8396|  1.17k|    combined += it->second;
 8397|  1.17k|  }
 8398|  1.81k|  return combined;
 8399|  1.81k|}
_ZN7httplib6detail19create_decompressorERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8310|    241|create_decompressor(const std::string &encoding) {
 8311|    241|  std::unique_ptr<decompressor> decompressor;
 8312|       |
 8313|    241|  if (is_zlib_encoding(encoding)) {
  ------------------
  |  Branch (8313:7): [True: 148, False: 93]
  ------------------
 8314|    148|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
 8315|    148|    decompressor = detail::make_unique<gzip_decompressor>();
 8316|    148|#endif
 8317|    148|  } else if (is_brotli_encoding(encoding)) {
  ------------------
  |  Branch (8317:14): [True: 1, False: 92]
  ------------------
 8318|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
 8319|       |    decompressor = detail::make_unique<brotli_decompressor>();
 8320|       |#endif
 8321|     92|  } else if (is_zstd_encoding(encoding)) {
  ------------------
  |  Branch (8321:14): [True: 1, False: 91]
  ------------------
 8322|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
 8323|       |    decompressor = detail::make_unique<zstd_decompressor>();
 8324|       |#endif
 8325|      1|  }
 8326|       |
 8327|    241|  return decompressor;
 8328|    241|}
_ZN7httplib6detail16is_zlib_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8289|    334|inline bool is_zlib_encoding(const std::string &encoding) {
 8290|    334|  return case_ignore::equal(encoding, "gzip") ||
  ------------------
  |  Branch (8290:10): [True: 17, False: 317]
  ------------------
 8291|    317|         case_ignore::equal(encoding, "deflate");
  ------------------
  |  Branch (8291:10): [True: 131, False: 186]
  ------------------
 8292|    334|}
_ZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  695|    518|inline bool equal(const std::string &a, const char (&b)[N]) {
  696|    518|  return a.size() == N - 1 &&
  ------------------
  |  Branch (696:10): [True: 69, False: 449]
  ------------------
  697|     69|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (697:10): [True: 19, False: 50]
  ------------------
  698|     69|           return to_lower(ca) == to_lower(cb);
  699|     69|         });
  700|    518|}
_ZZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  697|    150|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  698|    150|           return to_lower(ca) == to_lower(cb);
  699|    150|         });
_ZN7httplib6detail11case_ignore5equalILm8EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  695|  1.26k|inline bool equal(const std::string &a, const char (&b)[N]) {
  696|  1.26k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (696:10): [True: 855, False: 405]
  ------------------
  697|    855|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (697:10): [True: 825, False: 30]
  ------------------
  698|    855|           return to_lower(ca) == to_lower(cb);
  699|    855|         });
  700|  1.26k|}
_ZZN7httplib6detail11case_ignore5equalILm8EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  697|  5.86k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  698|  5.86k|           return to_lower(ca) == to_lower(cb);
  699|  5.86k|         });
_ZN7httplib6detail11make_uniqueINS0_17gzip_decompressorEJEEENSt3__19enable_ifIXntsr3std8is_arrayIT_EE5valueENS3_10unique_ptrIS5_NS3_14default_deleteIS5_EEEEE4typeEDpOT0_:
  626|    148|make_unique(Args &&...args) {
  627|    148|  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  628|    148|}
_ZN7httplib6detail17gzip_decompressorC2Ev:
 8084|    148|inline gzip_decompressor::gzip_decompressor() {
 8085|    148|  std::memset(&strm_, 0, sizeof(strm_));
 8086|    148|  strm_.zalloc = Z_NULL;
 8087|    148|  strm_.zfree = Z_NULL;
 8088|    148|  strm_.opaque = Z_NULL;
 8089|       |
 8090|       |  // 15 is the value of wbits, which should be at the maximum possible value
 8091|       |  // to ensure that any gzip stream can be decoded. The offset of 32 specifies
 8092|       |  // that the stream type should be automatically detected either gzip or
 8093|       |  // deflate.
 8094|    148|  is_valid_ = inflateInit2(&strm_, 32 + 15) == Z_OK;
 8095|    148|}
_ZN7httplib6detail18is_brotli_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8294|    186|inline bool is_brotli_encoding(const std::string &encoding) {
 8295|    186|  return case_ignore::equal(encoding, "br");
 8296|    186|}
_ZN7httplib6detail11case_ignore5equalILm3EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  695|    186|inline bool equal(const std::string &a, const char (&b)[N]) {
  696|    186|  return a.size() == N - 1 &&
  ------------------
  |  Branch (696:10): [True: 30, False: 156]
  ------------------
  697|     30|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (697:10): [True: 2, False: 28]
  ------------------
  698|     30|           return to_lower(ca) == to_lower(cb);
  699|     30|         });
  700|    186|}
_ZZN7httplib6detail11case_ignore5equalILm3EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  697|     36|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  698|     36|           return to_lower(ca) == to_lower(cb);
  699|     36|         });
_ZN7httplib6detail16is_zstd_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8298|    184|inline bool is_zstd_encoding(const std::string &encoding) {
 8299|    184|  return case_ignore::equal(encoding, "zstd");
 8300|    184|}
_ZN7httplib6detail25is_known_content_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8304|     93|inline bool is_known_content_encoding(const std::string &encoding) {
 8305|     93|  return is_zlib_encoding(encoding) || is_brotli_encoding(encoding) ||
  ------------------
  |  Branch (8305:10): [True: 0, False: 93]
  |  Branch (8305:40): [True: 1, False: 92]
  ------------------
 8306|     92|         is_zstd_encoding(encoding);
  ------------------
  |  Branch (8306:10): [True: 1, False: 91]
  ------------------
 8307|     93|}
_ZZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_ENKUlSE_mmmE_clESE_mmm:
 8794|  2.83k|                                              size_t off, size_t len) {
 8795|  2.83k|          return decompressor->decompress(
 8796|  2.83k|              buf, n, [&](const char *buf2, size_t n2) {
 8797|       |                // Guard against zip-bomb: check
 8798|       |                // decompressed size against limit.
 8799|  2.83k|                if (payload_max_length > 0 &&
 8800|  2.83k|                    (decompressed_size >= payload_max_length ||
 8801|  2.83k|                     n2 > payload_max_length - decompressed_size)) {
 8802|  2.83k|                  exceed_payload_max_length = true;
 8803|  2.83k|                  return false;
 8804|  2.83k|                }
 8805|  2.83k|                decompressed_size += n2;
 8806|  2.83k|                return receiver(buf2, n2, off, len);
 8807|  2.83k|              });
 8808|  2.83k|        };
_ZZZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_ENKUlSE_mmmE_clESE_mmmENKUlSE_mE_clESE_m:
 8796|   123k|              buf, n, [&](const char *buf2, size_t n2) {
 8797|       |                // Guard against zip-bomb: check
 8798|       |                // decompressed size against limit.
 8799|   123k|                if (payload_max_length > 0 &&
  ------------------
  |  Branch (8799:21): [True: 123k, False: 0]
  ------------------
 8800|   123k|                    (decompressed_size >= payload_max_length ||
  ------------------
  |  Branch (8800:22): [True: 1, False: 123k]
  ------------------
 8801|   123k|                     n2 > payload_max_length - decompressed_size)) {
  ------------------
  |  Branch (8801:22): [True: 14, False: 123k]
  ------------------
 8802|     15|                  exceed_payload_max_length = true;
 8803|     15|                  return false;
 8804|     15|                }
 8805|   123k|                decompressed_size += n2;
 8806|   123k|                return receiver(buf2, n2, off, len);
 8807|   123k|              });
_ZZN7httplib6detail12read_contentINS_8ResponseEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEbENKUlRKSF_E_clESH_:
 8831|  1.66k|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 8832|  1.66k|        auto ret = true;
 8833|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 8834|       |        // wrapper in prepare_content_receiver when the decompressed payload
 8835|       |        // size exceeds the limit.
 8836|       |
 8837|  1.66k|        if (is_chunked_transfer_encoding(x.headers)) {
  ------------------
  |  Branch (8837:13): [True: 694, False: 975]
  ------------------
 8838|    694|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 8839|    694|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (8839:15): [True: 2, False: 692]
  ------------------
 8840|      2|            ret = true;
 8841|    692|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (8841:22): [True: 0, False: 692]
  ------------------
 8842|      0|            exceed_payload_max_length = true;
 8843|      0|            ret = false;
 8844|    692|          } else {
 8845|    692|            ret = false;
 8846|    692|          }
 8847|    975|        } else if (!has_header(x.headers, "Content-Length")) {
  ------------------
  |  Branch (8847:20): [True: 501, False: 474]
  ------------------
 8848|    501|          auto result =
 8849|    501|              read_content_without_length(strm, payload_max_length, out);
 8850|    501|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (8850:15): [True: 472, False: 29]
  ------------------
 8851|    472|            ret = true;
 8852|    472|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (8852:22): [True: 0, False: 29]
  ------------------
 8853|      0|            exceed_payload_max_length = true;
 8854|      0|            ret = false;
 8855|     29|          } else {
 8856|     29|            ret = false;
 8857|     29|          }
 8858|    501|        } else {
 8859|    474|          auto is_invalid_value = false;
 8860|    474|          auto len = get_header_value_u64(x.headers, "Content-Length",
 8861|    474|                                          (std::numeric_limits<size_t>::max)(),
 8862|    474|                                          0, is_invalid_value);
 8863|       |
 8864|    474|          if (is_invalid_value) {
  ------------------
  |  Branch (8864:15): [True: 76, False: 398]
  ------------------
 8865|     76|            ret = false;
 8866|    398|          } else if (len > 0) {
  ------------------
  |  Branch (8866:22): [True: 394, False: 4]
  ------------------
 8867|    394|            auto result = read_content_with_length(
 8868|    394|                strm, len, std::move(progress), out, payload_max_length);
 8869|    394|            ret = (result == ReadContentResult::Success);
 8870|    394|            if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (8870:17): [True: 0, False: 394]
  ------------------
 8871|      0|              exceed_payload_max_length = true;
 8872|      0|            }
 8873|    394|          }
 8874|    474|        }
 8875|       |
 8876|  1.66k|        if (!ret) {
  ------------------
  |  Branch (8876:13): [True: 1.18k, False: 480]
  ------------------
 8877|  1.18k|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
  ------------------
  |  Branch (8877:20): [True: 15, False: 1.17k]
  ------------------
 8878|  1.18k|                                             : StatusCode::BadRequest_400;
 8879|  1.18k|        }
 8880|  1.66k|        return ret;
 8881|  1.66k|      });
_ZN7httplib6detail28is_chunked_transfer_encodingERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 8719|  1.66k|inline bool is_chunked_transfer_encoding(const Headers &headers) {
 8720|       |  // RFC 9112 6.1: a message is framed with the chunked coding when "chunked"
 8721|       |  // is the final transfer coding. A single field value may list several
 8722|       |  // codings ("gzip, chunked"), and RFC 9110 5.3 lets that list be split across
 8723|       |  // several Transfer-Encoding lines, which combine into one comma-separated
 8724|       |  // list in the order the lines were received. Headers preserves that order,
 8725|       |  // so the final coding is the last token of the last line. Match it
 8726|       |  // case-insensitively rather than comparing the whole value against
 8727|       |  // "chunked".
 8728|       |  //
 8729|       |  // Security: reading a chunked message as unframed leaves its body in the
 8730|       |  // socket, where a keep-alive connection parses it as a smuggled request.
 8731|       |  // Server::process_request() answers 400 and closes when the final coding is
 8732|       |  // not chunked, so a request whose framing cannot be determined never
 8733|       |  // reaches the "no body" path.
 8734|  1.66k|  auto rng = headers.equal_range("Transfer-Encoding");
 8735|  1.66k|  if (rng.first == rng.second) { return false; }
  ------------------
  |  Branch (8735:7): [True: 726, False: 943]
  ------------------
 8736|       |
 8737|       |  // Cleared per line, so a trailing line carrying no coding at all leaves the
 8738|       |  // combined list ending in nothing rather than inheriting the line before it.
 8739|    943|  std::string last_coding;
 8740|       |
 8741|  2.22k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (8741:29): [True: 1.27k, False: 943]
  ------------------
 8742|  1.27k|    const auto &value = it->second;
 8743|  1.27k|    last_coding.clear();
 8744|  1.27k|    split(value.data(), value.data() + value.size(), ',',
 8745|  1.27k|          [&](const char *b, const char *e) { last_coding.assign(b, e); });
 8746|  1.27k|  }
 8747|       |
 8748|    943|  return case_ignore::equal(last_coding, "chunked");
 8749|  1.66k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEeqISF_EEbRKNSC_IT_EE:
 1222|  1.66k|    template <typename U> bool operator==(const iterator_t<U> &rhs) const {
 1223|  1.66k|      return idx_ == rhs.idx_;
 1224|  1.66k|    }
_ZZN7httplib6detail28is_chunked_transfer_encodingERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEEENKUlPKcSF_E_clESF_SF_:
 8745|  5.76k|          [&](const char *b, const char *e) { last_coding.assign(b, e); });
_ZN7httplib6detail20read_content_chunkedINS_8ResponseEEENS0_17ReadContentResultERNS_6StreamERT_mNSt3__18functionIFbPKcmmmEEE:
 8686|    694|                                              ContentReceiverWithProgress out) {
 8687|    694|  detail::ChunkedDecoder dec(strm);
 8688|       |
 8689|    694|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 8690|    694|  size_t total_len = 0;
 8691|       |
 8692|  4.75k|  for (;;) {
 8693|  4.75k|    size_t chunk_offset = 0;
 8694|  4.75k|    size_t chunk_total = 0;
 8695|  4.75k|    auto n = dec.read_payload(buf, sizeof(buf), chunk_offset, chunk_total);
 8696|  4.75k|    if (n < 0) { return ReadContentResult::Error; }
  ------------------
  |  Branch (8696:9): [True: 524, False: 4.23k]
  ------------------
 8697|       |
 8698|  4.23k|    if (n == 0) {
  ------------------
  |  Branch (8698:9): [True: 168, False: 4.06k]
  ------------------
 8699|    168|      if (!dec.parse_trailers_into(x.trailers, x.headers)) {
  ------------------
  |  Branch (8699:11): [True: 166, False: 2]
  ------------------
 8700|    166|        return ReadContentResult::Error;
 8701|    166|      }
 8702|      2|      return ReadContentResult::Success;
 8703|    168|    }
 8704|       |
 8705|  4.06k|    if (payload_max_length > 0 &&
  ------------------
  |  Branch (8705:9): [True: 4.06k, False: 0]
  ------------------
 8706|  4.06k|        (total_len > payload_max_length ||
  ------------------
  |  Branch (8706:10): [True: 0, False: 4.06k]
  ------------------
 8707|  4.06k|         payload_max_length - total_len < static_cast<size_t>(n))) {
  ------------------
  |  Branch (8707:10): [True: 0, False: 4.06k]
  ------------------
 8708|      0|      return ReadContentResult::PayloadTooLarge;
 8709|      0|    }
 8710|       |
 8711|  4.06k|    if (!out(buf, static_cast<size_t>(n), chunk_offset, chunk_total)) {
  ------------------
  |  Branch (8711:9): [True: 2, False: 4.06k]
  ------------------
 8712|      2|      return ReadContentResult::Error;
 8713|      2|    }
 8714|       |
 8715|  4.06k|    total_len += static_cast<size_t>(n);
 8716|  4.06k|  }
 8717|    694|}
_ZN7httplib6detail14ChunkedDecoderC2ERNS_6StreamE:
16065|    694|inline ChunkedDecoder::ChunkedDecoder(Stream &s) : strm(s) {}
_ZN7httplib6detail14ChunkedDecoder12read_payloadEPcmRmS3_:
16069|  4.75k|                                            size_t &out_chunk_total) {
16070|  4.75k|  if (finished) { return 0; }
  ------------------
  |  Branch (16070:7): [True: 0, False: 4.75k]
  ------------------
16071|       |
16072|  4.75k|  if (chunk_remaining == 0) {
  ------------------
  |  Branch (16072:7): [True: 4.06k, False: 690]
  ------------------
16073|  4.06k|    stream_line_reader lr(strm, line_buf, sizeof(line_buf));
16074|  4.06k|    if (!lr.getline()) { return -1; }
  ------------------
  |  Branch (16074:9): [True: 25, False: 4.04k]
  ------------------
16075|       |
16076|       |    // Everything below is bounded by eol rather than by the buffer's NUL, so
16077|       |    // the line terminator is never mistaken for line content.
16078|  4.04k|    const char *eol = lr.ptr() + lr.size();
16079|  4.04k|    if (lr.end_with_crlf()) {
  ------------------
  |  Branch (16079:9): [True: 3.76k, False: 274]
  ------------------
16080|  3.76k|      eol -= 2;
16081|  3.76k|    } else if (eol != lr.ptr() && eol[-1] == '\n') {
  ------------------
  |  Branch (16081:16): [True: 274, False: 0]
  |  Branch (16081:35): [True: 7, False: 267]
  ------------------
16082|       |      // Only reachable under CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR, where
16083|       |      // getline() ends the line on a bare LF. That LF is the terminator, so it
16084|       |      // has to come off here or the check below would reject the line.
16085|      7|      eol -= 1;
16086|      7|    }
16087|       |
16088|       |    // RFC 9112 §7.1: chunk-size = 1*HEXDIG
16089|  4.04k|    const char *p = lr.ptr();
16090|  4.04k|    int v = 0;
16091|  4.04k|    if (p == eol || !is_hex(*p, v)) { return -1; }
  ------------------
  |  Branch (16091:9): [True: 9, False: 4.03k]
  |  Branch (16091:21): [True: 40, False: 3.99k]
  ------------------
16092|       |
16093|  3.99k|    size_t chunk_len = 0;
16094|  3.99k|    constexpr size_t chunk_len_max = (std::numeric_limits<size_t>::max)();
16095|  11.5k|    for (; p < eol && is_hex(*p, v); ++p) {
  ------------------
  |  Branch (16095:12): [True: 7.99k, False: 3.51k]
  |  Branch (16095:23): [True: 7.52k, False: 471]
  ------------------
16096|  7.52k|      if (chunk_len > (chunk_len_max >> 4)) { return -1; }
  ------------------
  |  Branch (16096:11): [True: 11, False: 7.51k]
  ------------------
16097|  7.51k|      chunk_len = (chunk_len << 4) | static_cast<size_t>(v);
16098|  7.51k|    }
16099|       |
16100|  5.12k|    while (p < eol && is_space_or_tab(*p)) {
  ------------------
  |  Branch (16100:12): [True: 1.59k, False: 3.53k]
  |  Branch (16100:23): [True: 1.14k, False: 447]
  ------------------
16101|  1.14k|      ++p;
16102|  1.14k|    }
16103|       |
16104|       |    // RFC 9112 §7.1.1: only a chunk-ext may sit between the size and the line
16105|       |    // terminator, and it is built from tokens and quoted-strings, so it never
16106|       |    // holds a CR, LF or any other control character. getline() reads up to the
16107|       |    // CRLF, so a bare LF left in here would be swallowed as extension text
16108|       |    // while an intermediary that ends the line on it delimits the chunks
16109|       |    // differently, and the two disagree on where the body ends (request
16110|       |    // smuggling).
16111|  3.98k|    if (p < eol && *p != ';') { return -1; }
  ------------------
  |  Branch (16111:9): [True: 447, False: 3.53k]
  |  Branch (16111:20): [True: 30, False: 417]
  ------------------
16112|  16.1k|    for (; p < eol; ++p) {
  ------------------
  |  Branch (16112:12): [True: 12.2k, False: 3.94k]
  ------------------
16113|  12.2k|      if (!is_space_or_tab(*p) && !fields::is_field_vchar(*p)) { return -1; }
  ------------------
  |  Branch (16113:11): [True: 2.37k, False: 9.82k]
  |  Branch (16113:35): [True: 3, False: 2.37k]
  ------------------
16114|  12.2k|    }
16115|       |
16116|  3.94k|    if (chunk_len == 0) {
  ------------------
  |  Branch (16116:9): [True: 168, False: 3.78k]
  ------------------
16117|    168|      chunk_remaining = 0;
16118|    168|      finished = true;
16119|    168|      out_chunk_offset = 0;
16120|    168|      out_chunk_total = 0;
16121|    168|      return 0;
16122|    168|    }
16123|       |
16124|  3.78k|    chunk_remaining = chunk_len;
16125|  3.78k|    last_chunk_total = chunk_remaining;
16126|  3.78k|    last_chunk_offset = 0;
16127|  3.78k|  }
16128|       |
16129|  4.47k|  auto to_read = (std::min)(chunk_remaining, len);
16130|  4.47k|  auto n = strm.read(buf, to_read);
16131|  4.47k|  if (n <= 0) { return -1; }
  ------------------
  |  Branch (16131:7): [True: 366, False: 4.10k]
  ------------------
16132|       |
16133|  4.10k|  auto offset_before = last_chunk_offset;
16134|  4.10k|  last_chunk_offset += static_cast<size_t>(n);
16135|  4.10k|  chunk_remaining -= static_cast<size_t>(n);
16136|       |
16137|  4.10k|  out_chunk_offset = offset_before;
16138|  4.10k|  out_chunk_total = last_chunk_total;
16139|       |
16140|  4.10k|  if (chunk_remaining == 0) {
  ------------------
  |  Branch (16140:7): [True: 3.41k, False: 692]
  ------------------
16141|  3.41k|    stream_line_reader lr(strm, line_buf, sizeof(line_buf));
16142|  3.41k|    if (!lr.getline()) { return -1; }
  ------------------
  |  Branch (16142:9): [True: 2, False: 3.41k]
  ------------------
16143|  3.41k|    if (std::strcmp(lr.ptr(), "\r\n") != 0) { return -1; }
  ------------------
  |  Branch (16143:9): [True: 38, False: 3.37k]
  ------------------
16144|  3.41k|  }
16145|       |
16146|  4.06k|  return n;
16147|  4.10k|}
_ZN7httplib6detail14ChunkedDecoder19parse_trailers_intoERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSC_:
16150|    168|                                                const Headers &src_headers) {
16151|    168|  stream_line_reader lr(strm, line_buf, sizeof(line_buf));
16152|    168|  if (!lr.getline()) { return false; }
  ------------------
  |  Branch (16152:7): [True: 21, False: 147]
  ------------------
16153|    147|  return parse_trailers(lr, dest, src_headers);
16154|    168|}
_ZN7httplib6detail14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSD_:
 6148|    147|                           const Headers &src_headers) {
 6149|       |  // NOTE: In RFC 9112, '7.1 Chunked Transfer Coding' mentions "The chunked
 6150|       |  // transfer coding is complete when a chunk with a chunk-size of zero is
 6151|       |  // received, possibly followed by a trailer section, and finally terminated by
 6152|       |  // an empty line". https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
 6153|       |  //
 6154|       |  // In '7.1.3. Decoding Chunked', however, the pseudo-code in the section
 6155|       |  // doesn't care for the existence of the final CRLF. In other words, it seems
 6156|       |  // to be ok whether the final CRLF exists or not in the chunked data.
 6157|       |  // https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1.3
 6158|       |  //
 6159|       |  // According to the reference code in RFC 9112, cpp-httplib now allows
 6160|       |  // chunked transfer coding data without the final CRLF.
 6161|       |
 6162|       |  // RFC 7230 Section 4.1.2 - Headers prohibited in trailers
 6163|    147|  thread_local case_ignore::unordered_set<std::string> prohibited_trailers = {
 6164|    147|      "transfer-encoding",
 6165|    147|      "content-length",
 6166|    147|      "host",
 6167|    147|      "authorization",
 6168|    147|      "www-authenticate",
 6169|    147|      "proxy-authenticate",
 6170|    147|      "proxy-authorization",
 6171|    147|      "cookie",
 6172|    147|      "set-cookie",
 6173|    147|      "cache-control",
 6174|    147|      "expect",
 6175|    147|      "max-forwards",
 6176|    147|      "pragma",
 6177|    147|      "range",
 6178|    147|      "te",
 6179|    147|      "age",
 6180|    147|      "expires",
 6181|    147|      "date",
 6182|    147|      "location",
 6183|    147|      "retry-after",
 6184|    147|      "vary",
 6185|    147|      "warning",
 6186|    147|      "content-encoding",
 6187|    147|      "content-type",
 6188|    147|      "content-range",
 6189|    147|      "trailer"};
 6190|       |
 6191|    147|  case_ignore::unordered_set<std::string> declared_trailers;
 6192|    147|  auto trailer_header = get_combined_header_value(src_headers, "Trailer");
 6193|    147|  if (!trailer_header.empty()) {
  ------------------
  |  Branch (6193:7): [True: 0, False: 147]
  ------------------
 6194|       |    // split() trims each token and skips empty ones, so the name arrives ready
 6195|       |    // to look up.
 6196|      0|    split(trailer_header.data(), trailer_header.data() + trailer_header.size(),
 6197|      0|          ',', [&](const char *b, const char *e) {
 6198|       |            // A legitimate message declares only a handful of trailers. Cap the
 6199|       |            // set so a peer cannot grow it without bound: an oversized set only
 6200|       |            // arises from an attempt to force many colliding names into
 6201|       |            // quadratic lookups (case_ignore::hash is unkeyed).
 6202|      0|            if (declared_trailers.size() >= CPPHTTPLIB_HEADER_MAX_COUNT) {
 6203|      0|              return;
 6204|      0|            }
 6205|      0|            std::string key(b, e);
 6206|      0|            if (prohibited_trailers.find(key) == prohibited_trailers.end()) {
 6207|      0|              declared_trailers.insert(key);
 6208|      0|            }
 6209|      0|          });
 6210|      0|  }
 6211|       |
 6212|    147|  size_t trailer_header_count = 0;
 6213|  1.43k|  while (strcmp(line_reader.ptr(), "\r\n") != 0) {
  ------------------
  |  Branch (6213:10): [True: 1.43k, False: 2]
  ------------------
 6214|  1.43k|    if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
  ------------------
  |  |  122|  1.43k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (6214:9): [True: 1, False: 1.43k]
  ------------------
 6215|       |    // Count every received trailer field, not only the declared ones stored in
 6216|       |    // dest, so undeclared fields cannot keep this loop running past the limit.
 6217|  1.43k|    if (trailer_header_count >= CPPHTTPLIB_HEADER_MAX_COUNT) { return false; }
  ------------------
  |  |  126|  1.43k|#define CPPHTTPLIB_HEADER_MAX_COUNT 100
  ------------------
  |  Branch (6217:9): [True: 1, False: 1.43k]
  ------------------
 6218|       |
 6219|  1.43k|    constexpr auto line_terminator_len = 2;
 6220|  1.43k|    auto line_beg = line_reader.ptr();
 6221|  1.43k|    auto line_end =
 6222|  1.43k|        line_reader.ptr() + line_reader.size() - line_terminator_len;
 6223|       |
 6224|  1.43k|    if (!parse_header(line_beg, line_end,
  ------------------
  |  Branch (6224:9): [True: 108, False: 1.32k]
  ------------------
 6225|  1.43k|                      [&](const std::string &key, const std::string &val) {
 6226|  1.43k|                        if (declared_trailers.find(key) !=
 6227|  1.43k|                            declared_trailers.end()) {
 6228|  1.43k|                          dest.emplace(key, val);
 6229|  1.43k|                        }
 6230|  1.43k|                      })) {
 6231|    108|      return false;
 6232|    108|    }
 6233|       |
 6234|  1.32k|    trailer_header_count++;
 6235|       |
 6236|  1.32k|    if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (6236:9): [True: 35, False: 1.29k]
  ------------------
 6237|  1.32k|  }
 6238|       |
 6239|      2|  return true;
 6240|    147|}
_ZNK7httplib6detail11case_ignore4hashclERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
  709|     26|  size_t operator()(const std::string &key) const {
  710|     26|    size_t h = 0;
  711|    253|    for (auto c : key) {
  ------------------
  |  Branch (711:17): [True: 253, False: 26]
  ------------------
  712|       |      // Unsets the 6 high bits of h, therefore no overflow happens
  713|    253|      h = (((std::numeric_limits<size_t>::max)() >> 6) & h * 33) ^
  714|    253|          static_cast<unsigned char>(to_lower(c));
  715|    253|    }
  716|     26|    return h;
  717|     26|  }
_ZN7httplib6detail12parse_headerIZNS0_14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSE_EUlRKSB_SJ_E_EEbPKcSM_T_:
 6102|  1.43k|inline bool parse_header(const char *beg, const char *end, T fn) {
 6103|       |  // Skip trailing spaces and tabs.
 6104|  1.79k|  while (beg < end && is_space_or_tab(end[-1])) {
  ------------------
  |  Branch (6104:10): [True: 1.75k, False: 42]
  |  Branch (6104:23): [True: 364, False: 1.39k]
  ------------------
 6105|    364|    end--;
 6106|    364|  }
 6107|       |
 6108|  1.43k|  auto p = beg;
 6109|  83.9k|  while (p < end && *p != ':') {
  ------------------
  |  Branch (6109:10): [True: 83.8k, False: 79]
  |  Branch (6109:21): [True: 82.4k, False: 1.35k]
  ------------------
 6110|  82.4k|    p++;
 6111|  82.4k|  }
 6112|       |
 6113|  1.43k|  auto name = std::string(beg, p);
 6114|  1.43k|  if (!detail::fields::is_field_name(name)) { return false; }
  ------------------
  |  Branch (6114:7): [True: 76, False: 1.35k]
  ------------------
 6115|       |
 6116|  1.35k|  if (p == end) { return false; }
  ------------------
  |  Branch (6116:7): [True: 15, False: 1.34k]
  ------------------
 6117|       |
 6118|  1.34k|  auto key_end = p;
 6119|       |
 6120|  1.34k|  if (*p++ != ':') { return false; }
  ------------------
  |  Branch (6120:7): [True: 0, False: 1.34k]
  ------------------
 6121|       |
 6122|  1.72k|  while (p < end && is_space_or_tab(*p)) {
  ------------------
  |  Branch (6122:10): [True: 744, False: 979]
  |  Branch (6122:21): [True: 380, False: 364]
  ------------------
 6123|    380|    p++;
 6124|    380|  }
 6125|       |
 6126|  1.34k|  if (p <= end) {
  ------------------
  |  Branch (6126:7): [True: 1.34k, False: 0]
  ------------------
 6127|  1.34k|    auto key_len = key_end - beg;
 6128|  1.34k|    if (!key_len) { return false; }
  ------------------
  |  Branch (6128:9): [True: 0, False: 1.34k]
  ------------------
 6129|       |
 6130|  1.34k|    auto key = std::string(beg, key_end);
 6131|  1.34k|    auto val = std::string(p, end);
 6132|       |
 6133|  1.34k|    if (!detail::fields::is_field_value(val)) { return false; }
  ------------------
  |  Branch (6133:9): [True: 17, False: 1.32k]
  ------------------
 6134|       |
 6135|       |    // RFC 9110 §5.5: header field values are opaque octets and MUST NOT be
 6136|       |    // percent-decoded by the recipient. Applications that need to interpret a
 6137|       |    // value as a URI component should call httplib::decode_uri_component()
 6138|       |    // (or decode_path_component()) explicitly.
 6139|  1.32k|    fn(key, val);
 6140|       |
 6141|  1.32k|    return true;
 6142|  1.34k|  }
 6143|       |
 6144|      0|  return false;
 6145|  1.34k|}
_ZZN7httplib6detail14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSD_ENKUlRKSA_SI_E_clESI_SI_:
 6225|  1.32k|                      [&](const std::string &key, const std::string &val) {
 6226|  1.32k|                        if (declared_trailers.find(key) !=
  ------------------
  |  Branch (6226:29): [True: 0, False: 1.32k]
  ------------------
 6227|  1.32k|                            declared_trailers.end()) {
 6228|      0|                          dest.emplace(key, val);
 6229|      0|                        }
 6230|  1.32k|                      })) {
_ZN7httplib6detail27read_content_without_lengthERNS_6StreamEmNSt3__18functionIFbPKcmmmEEE:
 8659|    501|                            ContentReceiverWithProgress out) {
 8660|    501|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 8661|    501|  size_t r = 0;
 8662|  1.77k|  for (;;) {
 8663|  1.77k|    auto n = strm.read(buf, CPPHTTPLIB_RECV_BUFSIZ);
  ------------------
  |  |  188|  1.77k|#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
  ------------------
 8664|  1.77k|    if (n == 0) { return ReadContentResult::Success; }
  ------------------
  |  Branch (8664:9): [True: 472, False: 1.30k]
  ------------------
 8665|  1.30k|    if (n < 0) { return ReadContentResult::Error; }
  ------------------
  |  Branch (8665:9): [True: 0, False: 1.30k]
  ------------------
 8666|       |
 8667|       |    // Check if adding this data would exceed the payload limit
 8668|  1.30k|    if (payload_max_length > 0 &&
  ------------------
  |  Branch (8668:9): [True: 1.30k, False: 0]
  ------------------
 8669|  1.30k|        (r > payload_max_length ||
  ------------------
  |  Branch (8669:10): [True: 0, False: 1.30k]
  ------------------
 8670|  1.30k|         payload_max_length - r < static_cast<size_t>(n))) {
  ------------------
  |  Branch (8670:10): [True: 0, False: 1.30k]
  ------------------
 8671|      0|      return ReadContentResult::PayloadTooLarge;
 8672|      0|    }
 8673|       |
 8674|  1.30k|    if (!out(buf, static_cast<size_t>(n), r, 0)) {
  ------------------
  |  Branch (8674:9): [True: 29, False: 1.27k]
  ------------------
 8675|     29|      return ReadContentResult::Error;
 8676|     29|    }
 8677|  1.27k|    r += static_cast<size_t>(n);
 8678|  1.27k|  }
 8679|       |
 8680|      0|  return ReadContentResult::Success;
 8681|    501|}
_ZN7httplib6detail24read_content_with_lengthERNS_6StreamEmNSt3__18functionIFbmmEEENS4_IFbPKcmmmEEEm:
 8619|    394|    size_t payload_max_length = (std::numeric_limits<size_t>::max)()) {
 8620|    394|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 8621|       |
 8622|    394|  detail::BodyReader br;
 8623|    394|  br.stream = &strm;
 8624|    394|  br.has_content_length = true;
 8625|    394|  br.content_length = len;
 8626|    394|  br.payload_max_length = payload_max_length;
 8627|    394|  br.chunked = false;
 8628|    394|  br.bytes_read = 0;
 8629|    394|  br.last_error = Error::Success;
 8630|       |
 8631|    394|  size_t r = 0;
 8632|    994|  while (r < len) {
  ------------------
  |  Branch (8632:10): [True: 992, False: 2]
  ------------------
 8633|    992|    auto read_len = static_cast<size_t>(len - r);
 8634|    992|    auto to_read = (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ);
  ------------------
  |  |  188|    992|#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
  ------------------
 8635|    992|    auto n = detail::read_body_content(&strm, br, buf, to_read);
 8636|    992|    if (n <= 0) {
  ------------------
  |  Branch (8636:9): [True: 391, False: 601]
  ------------------
 8637|       |      // Check if it was a payload size error
 8638|    391|      if (br.last_error == Error::ExceedMaxPayloadSize) {
  ------------------
  |  Branch (8638:11): [True: 0, False: 391]
  ------------------
 8639|      0|        return ReadContentResult::PayloadTooLarge;
 8640|      0|      }
 8641|    391|      return ReadContentResult::Error;
 8642|    391|    }
 8643|       |
 8644|    601|    if (!out(buf, static_cast<size_t>(n), r, len)) {
  ------------------
  |  Branch (8644:9): [True: 1, False: 600]
  ------------------
 8645|      1|      return ReadContentResult::Error;
 8646|      1|    }
 8647|    600|    r += static_cast<size_t>(n);
 8648|       |
 8649|    600|    if (progress) {
  ------------------
  |  Branch (8649:9): [True: 600, False: 0]
  ------------------
 8650|    600|      if (!progress(r, len)) { return ReadContentResult::Error; }
  ------------------
  |  Branch (8650:11): [True: 0, False: 600]
  ------------------
 8651|    600|    }
 8652|    600|  }
 8653|       |
 8654|      2|  return ReadContentResult::Success;
 8655|    394|}
_ZN7httplib6detail17read_body_contentEPNS_6StreamERNS0_10BodyReaderEPcm:
 2710|    992|                                 size_t len) {
 2711|    992|  (void)stream;
 2712|    992|  return br.read(buf, len);
 2713|    992|}
_ZN7httplib6detail10BodyReader4readEPcm:
12400|    992|inline ssize_t detail::BodyReader::read(char *buf, size_t len) {
12401|    992|  if (!stream) {
  ------------------
  |  Branch (12401:7): [True: 0, False: 992]
  ------------------
12402|      0|    last_error = Error::Connection;
12403|      0|    return -1;
12404|      0|  }
12405|    992|  if (eof) { return 0; }
  ------------------
  |  Branch (12405:7): [True: 0, False: 992]
  ------------------
12406|       |
12407|    992|  if (!chunked) {
  ------------------
  |  Branch (12407:7): [True: 992, False: 0]
  ------------------
12408|       |    // Content-Length based reading
12409|    992|    if (has_content_length && bytes_read >= content_length) {
  ------------------
  |  Branch (12409:9): [True: 992, False: 0]
  |  Branch (12409:31): [True: 0, False: 992]
  ------------------
12410|      0|      eof = true;
12411|      0|      return 0;
12412|      0|    }
12413|       |
12414|    992|    auto to_read = len;
12415|    992|    if (has_content_length) {
  ------------------
  |  Branch (12415:9): [True: 992, False: 0]
  ------------------
12416|    992|      auto remaining = content_length - bytes_read;
12417|    992|      to_read = (std::min)(len, remaining);
12418|    992|    }
12419|    992|    auto n = stream->read(buf, to_read);
12420|       |
12421|       |    // Without Content-Length the body ends when the connection closes
12422|       |    // (RFC 9112 §6.3); with one, an EOF here came too early
12423|    992|    if (n < 0 || (n == 0 && has_content_length)) {
  ------------------
  |  Branch (12423:9): [True: 0, False: 992]
  |  Branch (12423:19): [True: 391, False: 601]
  |  Branch (12423:29): [True: 391, False: 0]
  ------------------
12424|    391|      last_error = stream->get_error();
12425|    391|      if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (12425:11): [True: 391, False: 0]
  ------------------
12426|    391|    }
12427|    992|    if (n <= 0) {
  ------------------
  |  Branch (12427:9): [True: 391, False: 601]
  ------------------
12428|    391|      eof = true;
12429|    391|      return n;
12430|    391|    }
12431|       |
12432|    601|    bytes_read += static_cast<size_t>(n);
12433|    601|    if (has_content_length && bytes_read >= content_length) { eof = true; }
  ------------------
  |  Branch (12433:9): [True: 601, False: 0]
  |  Branch (12433:31): [True: 2, False: 599]
  ------------------
12434|    601|    if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (12434:9): [True: 601, False: 0]
  |  Branch (12434:35): [True: 0, False: 601]
  ------------------
12435|      0|      last_error = Error::ExceedMaxPayloadSize;
12436|      0|      eof = true;
12437|      0|      return -1;
12438|      0|    }
12439|    601|    return n;
12440|    601|  }
12441|       |
12442|       |  // Chunked transfer encoding: delegate to shared decoder instance.
12443|      0|  if (!chunked_decoder) { chunked_decoder.reset(new ChunkedDecoder(*stream)); }
  ------------------
  |  Branch (12443:7): [True: 0, False: 0]
  ------------------
12444|       |
12445|      0|  size_t chunk_offset = 0;
12446|      0|  size_t chunk_total = 0;
12447|      0|  auto n = chunked_decoder->read_payload(buf, len, chunk_offset, chunk_total);
12448|      0|  if (n < 0) {
  ------------------
  |  Branch (12448:7): [True: 0, False: 0]
  ------------------
12449|      0|    last_error = stream->get_error();
12450|      0|    if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (12450:9): [True: 0, False: 0]
  ------------------
12451|      0|    eof = true;
12452|      0|    return n;
12453|      0|  }
12454|       |
12455|      0|  if (n == 0) {
  ------------------
  |  Branch (12455:7): [True: 0, False: 0]
  ------------------
12456|       |    // Final chunk observed. Leave trailer parsing to the caller (StreamHandle).
12457|      0|    eof = true;
12458|      0|    return 0;
12459|      0|  }
12460|       |
12461|      0|  bytes_read += static_cast<size_t>(n);
12462|      0|  if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (12462:7): [True: 0, False: 0]
  |  Branch (12462:33): [True: 0, False: 0]
  ------------------
12463|      0|    last_error = Error::ExceedMaxPayloadSize;
12464|      0|    eof = true;
12465|      0|    return -1;
12466|      0|  }
12467|      0|  return n;
12468|      0|}
_ZNK7httplib6Stream9get_errorEv:
 2044|    391|  Error get_error() const { return error_; }
_ZZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_ENKUlSE_mmmE0_clESE_mmm:
 8818|  3.13k|                                        size_t len) {
 8819|  3.13k|    return receiver(buf, n, off, len);
 8820|  3.13k|  };
_ZZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorEENKUlmmE_clEmm:
16993|    600|    auto progress = [&](size_t current, size_t total) {
16994|    600|      if (!req.download_progress || redirect) { return true; }
  ------------------
  |  Branch (16994:11): [True: 600, False: 0]
  |  Branch (16994:37): [True: 0, False: 0]
  ------------------
16995|      0|      auto ret = req.download_progress(current, total);
16996|      0|      if (!ret) { error = Error::Canceled; }
  ------------------
  |  Branch (16996:11): [True: 0, False: 0]
  ------------------
16997|      0|      return ret;
16998|    600|    };
_ZNK7httplib10ClientImpl10output_logERKNS_7RequestERKNS_8ResponseE:
16828|    501|                                   const Response &res) const {
16829|    501|  if (logger_) {
  ------------------
  |  Branch (16829:7): [True: 0, False: 501]
  ------------------
16830|      0|    std::lock_guard<std::mutex> guard(logger_mutex_);
16831|      0|    logger_(req, res);
16832|      0|  }
16833|    501|}
_ZN7httplib8ResponseD2Ev:
 1926|  3.13k|  ~Response() {
 1927|  3.13k|    if (content_provider_resource_releaser_) {
  ------------------
  |  Branch (1927:9): [True: 0, False: 3.13k]
  ------------------
 1928|      0|      content_provider_resource_releaser_(content_provider_success_);
 1929|      0|    }
 1930|  3.13k|  }
_ZNK7httplib6detail17gzip_decompressor8is_validEv:
 8099|    148|inline bool gzip_decompressor::is_valid() const { return is_valid_; }
_ZN7httplib6detail17gzip_decompressor10decompressEPKcmNSt3__18functionIFbS3_mEEE:
 8102|  2.83k|                                          Callback callback) {
 8103|  2.83k|  assert(is_valid_);
  ------------------
  |  Branch (8103:3): [True: 2.83k, False: 0]
  ------------------
 8104|       |
 8105|  2.83k|  auto ret = Z_OK;
 8106|       |
 8107|  2.83k|  do {
 8108|  2.83k|    constexpr size_t max_avail_in =
 8109|  2.83k|        (std::numeric_limits<decltype(strm_.avail_in)>::max)();
 8110|       |
 8111|  2.83k|    strm_.avail_in = static_cast<decltype(strm_.avail_in)>(
 8112|  2.83k|        (std::min)(data_length, max_avail_in));
 8113|  2.83k|    strm_.next_in = const_cast<Bytef *>(reinterpret_cast<const Bytef *>(data));
 8114|       |
 8115|  2.83k|    data_length -= strm_.avail_in;
 8116|  2.83k|    data += strm_.avail_in;
 8117|       |
 8118|  2.83k|    std::array<char, CPPHTTPLIB_COMPRESSION_BUFSIZ> buff{};
 8119|   126k|    while (strm_.avail_in > 0 && ret == Z_OK) {
  ------------------
  |  Branch (8119:12): [True: 125k, False: 1.41k]
  |  Branch (8119:34): [True: 123k, False: 1.38k]
  ------------------
 8120|   123k|      strm_.avail_out = static_cast<uInt>(buff.size());
 8121|   123k|      strm_.next_out = reinterpret_cast<Bytef *>(buff.data());
 8122|       |
 8123|   123k|      ret = inflate(&strm_, Z_NO_FLUSH);
 8124|       |
 8125|   123k|      assert(ret != Z_STREAM_ERROR);
  ------------------
  |  Branch (8125:7): [True: 123k, False: 0]
  ------------------
 8126|   123k|      switch (ret) {
  ------------------
  |  Branch (8126:15): [True: 17, False: 123k]
  ------------------
 8127|      1|      case Z_NEED_DICT:
  ------------------
  |  Branch (8127:7): [True: 1, False: 123k]
  ------------------
 8128|     17|      case Z_DATA_ERROR:
  ------------------
  |  Branch (8128:7): [True: 16, False: 123k]
  ------------------
 8129|     17|      case Z_MEM_ERROR: inflateEnd(&strm_); return false;
  ------------------
  |  Branch (8129:7): [True: 0, False: 123k]
  ------------------
 8130|   123k|      }
 8131|       |
 8132|   123k|      if (!callback(buff.data(), buff.size() - strm_.avail_out)) {
  ------------------
  |  Branch (8132:11): [True: 15, False: 123k]
  ------------------
 8133|     15|        return false;
 8134|     15|      }
 8135|   123k|    }
 8136|       |
 8137|  2.80k|    if (ret != Z_OK && ret != Z_STREAM_END) { return false; }
  ------------------
  |  Branch (8137:9): [True: 1.38k, False: 1.41k]
  |  Branch (8137:24): [True: 0, False: 1.38k]
  ------------------
 8138|       |
 8139|  2.80k|  } while (data_length > 0);
  ------------------
  |  Branch (8139:12): [True: 0, False: 2.80k]
  ------------------
 8140|       |
 8141|  2.80k|  return true;
 8142|  2.83k|}
_ZN7httplib6detail12BufferStreamD2Ev:
 3852|  3.13k|  ~BufferStream() override = default;
_ZN7httplib6detail12BufferStream5writeEPKcm:
12820|  20.9k|inline ssize_t BufferStream::write(const char *ptr, size_t size) {
12821|  20.9k|  buffer.append(ptr, size);
12822|  20.9k|  return static_cast<ssize_t>(size);
12823|  20.9k|}
_ZNK7httplib6Stream13buffered_dataERm:
 2033|  3.97M|  virtual const char *buffered_data(size_t &size) const {
 2034|  3.97M|    size = 0;
 2035|  3.97M|    return nullptr;
 2036|  3.97M|  }
_ZNK7httplib10ClientImpl6is_sslEv:
17111|  3.13k|inline bool ClientImpl::is_ssl() const { return false; }

LLVMFuzzerTestOneInput:
   69|  3.13k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   70|  3.13k|  if (size < 1) return 0;
  ------------------
  |  Branch (70:7): [True: 0, False: 3.13k]
  ------------------
   71|       |
   72|  3.13k|  FuzzedStream stream{data + 1, size - 1};
   73|  3.13k|  FuzzableClient client;
   74|       |
   75|       |  // Use the first byte to select method
   76|  3.13k|  std::string method;
   77|  3.13k|  switch (data[0] % 6) {
  ------------------
  |  Branch (77:11): [True: 3.13k, False: 0]
  ------------------
   78|    154|  case 0: method = "GET"; break;
  ------------------
  |  Branch (78:3): [True: 154, False: 2.98k]
  ------------------
   79|    712|  case 1: method = "POST"; break;
  ------------------
  |  Branch (79:3): [True: 712, False: 2.42k]
  ------------------
   80|    950|  case 2: method = "PUT"; break;
  ------------------
  |  Branch (80:3): [True: 950, False: 2.18k]
  ------------------
   81|    435|  case 3: method = "PATCH"; break;
  ------------------
  |  Branch (81:3): [True: 435, False: 2.70k]
  ------------------
   82|    198|  case 4: method = "DELETE"; break;
  ------------------
  |  Branch (82:3): [True: 198, False: 2.94k]
  ------------------
   83|    689|  case 5: method = "OPTIONS"; break;
  ------------------
  |  Branch (83:3): [True: 689, False: 2.44k]
  ------------------
   84|  3.13k|  }
   85|       |
   86|  3.13k|  client.ProcessFuzzedResponse(stream, method);
   87|  3.13k|  return 0;
   88|  3.13k|}
_ZN12FuzzedStreamC2EPKhm:
    8|  3.13k|      : data_(data), size_(size), read_pos_(0) {}
_ZN12FuzzedStream4readEPcm:
   10|  3.98M|  ssize_t read(char *ptr, size_t size) override {
   11|  3.98M|    if (size + read_pos_ > size_) { size = size_ - read_pos_; }
  ------------------
  |  Branch (11:9): [True: 3.00k, False: 3.98M]
  ------------------
   12|  3.98M|    memcpy(ptr, data_ + read_pos_, size);
   13|  3.98M|    read_pos_ += size;
   14|  3.98M|    return static_cast<ssize_t>(size);
   15|  3.98M|  }
_ZN12FuzzedStream5writeEPKcm:
   17|  3.13k|  ssize_t write(const char *ptr, size_t size) override {
   18|  3.13k|    request_.append(ptr, size);
   19|  3.13k|    return static_cast<ssize_t>(size);
   20|  3.13k|  }
_ZN14FuzzableClientC2Ev:
   55|  3.13k|  FuzzableClient() : httplib::ClientImpl("localhost", 8080) {}
_ZN14FuzzableClient21ProcessFuzzedResponseER12FuzzedStreamRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
   57|  3.13k|  void ProcessFuzzedResponse(FuzzedStream &stream, const std::string &method) {
   58|  3.13k|    httplib::Request req;
   59|  3.13k|    req.method = method;
   60|  3.13k|    req.path = "/";
   61|  3.13k|    httplib::Response res;
   62|  3.13k|    bool close_connection = false;
   63|  3.13k|    httplib::Error error = httplib::Error::Success;
   64|       |
   65|  3.13k|    process_request(stream, req, res, close_connection, error);
   66|  3.13k|  }

