_ZN7httplib6detail17gzip_decompressorD2Ev:
 8878|    156|inline gzip_decompressor::~gzip_decompressor() { inflateEnd(&strm_); }
_ZN7httplib10ClientImplD2Ev:
16843|  3.31k|inline ClientImpl::~ClientImpl() {
16844|       |  // Wait until all the requests in flight are handled.
16845|  3.31k|  size_t retry_count = 10;
16846|  3.31k|  while (retry_count-- > 0) {
  ------------------
  |  Branch (16846:10): [True: 3.31k, False: 0]
  ------------------
16847|  3.31k|    {
16848|  3.31k|      std::lock_guard<std::mutex> guard(socket_mutex_);
16849|  3.31k|      if (socket_requests_in_flight_ == 0) { break; }
  ------------------
  |  Branch (16849:11): [True: 3.31k, False: 0]
  ------------------
16850|  3.31k|    }
16851|      0|    std::this_thread::sleep_for(std::chrono::milliseconds{1});
16852|      0|  }
16853|       |
16854|  3.31k|  std::lock_guard<std::mutex> guard(socket_mutex_);
16855|  3.31k|  shutdown_socket(socket_);
16856|  3.31k|  close_socket(socket_);
16857|  3.31k|}
_ZN7httplib6detail12decompressorD2Ev:
 4141|    156|  virtual ~decompressor() = default;
_ZN7httplib6StreamD2Ev:
 2047|  6.63k|  virtual ~Stream() = default;
_ZNK7httplib10ClientImpl15shutdown_socketERNS0_6SocketE:
16928|  3.31k|inline void ClientImpl::shutdown_socket(Socket &socket) const {
16929|  3.31k|  if (socket.sock == INVALID_SOCKET) { return; }
  ------------------
  |  |  395|  3.31k|#define INVALID_SOCKET (-1)
  ------------------
  |  Branch (16929:7): [True: 3.31k, False: 0]
  ------------------
16930|      0|  detail::shutdown_socket(socket.sock);
16931|      0|}
_ZN7httplib10ClientImpl12close_socketERNS0_6SocketE:
16933|  3.31k|inline void ClientImpl::close_socket(Socket &socket) {
16934|       |  // If there are requests in flight in another thread, usually closing
16935|       |  // the socket will be fine and they will simply receive an error when
16936|       |  // using the closed socket, but it is still a bug since rarely the OS
16937|       |  // may reassign the socket id to be used for a new socket, and then
16938|       |  // suddenly they will be operating on a live socket that is different
16939|       |  // than the one they intended!
16940|  3.31k|  assert(socket_requests_in_flight_ == 0 ||
  ------------------
  |  Branch (16940:3): [True: 3.31k, False: 0]
  |  Branch (16940:3): [True: 0, False: 0]
  |  Branch (16940:3): [True: 3.31k, False: 0]
  ------------------
16941|  3.31k|         socket_requests_are_from_thread_ == std::this_thread::get_id());
16942|       |
16943|       |  // It is also a bug if this happens while SSL is still active
16944|       |#ifdef CPPHTTPLIB_SSL_ENABLED
16945|       |  assert(socket.ssl == nullptr);
16946|       |#endif
16947|       |
16948|  3.31k|  if (socket.sock == INVALID_SOCKET) { return; }
  ------------------
  |  |  395|  3.31k|#define INVALID_SOCKET (-1)
  ------------------
  |  Branch (16948:7): [True: 3.31k, False: 0]
  ------------------
16949|      0|  detail::close_socket(socket.sock);
16950|      0|  socket.sock = INVALID_SOCKET;
  ------------------
  |  |  395|      0|#define INVALID_SOCKET (-1)
  ------------------
16951|      0|}
_ZN7httplib10ClientImplC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi:
16835|  3.31k|    : ClientImpl(host, port, std::string(), std::string()) {}
_ZN7httplib10ClientImplC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEiS9_S9_:
16840|  3.31k|    : host_(detail::escape_abstract_namespace_unix_domain(host)), port_(port),
16841|  3.31k|      client_cert_path_(client_cert_path), client_key_path_(client_key_path) {}
_ZN7httplib6detail37escape_abstract_namespace_unix_domainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 7454|  3.31k|inline std::string escape_abstract_namespace_unix_domain(const std::string &s) {
 7455|  3.31k|  if (s.size() > 1 && s[0] == '\0') {
  ------------------
  |  Branch (7455:7): [True: 3.31k, False: 0]
  |  Branch (7455:23): [True: 0, False: 3.31k]
  ------------------
 7456|      0|    auto ret = s;
 7457|      0|    ret[0] = '@';
 7458|      0|    return ret;
 7459|      0|  }
 7460|  3.31k|  return s;
 7461|  3.31k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEC2Ev:
 1299|  19.8k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail13write_headersERNS_6StreamERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9701|  3.31k|inline ssize_t write_headers(Stream &strm, const Headers &headers) {
 9702|  3.31k|  ssize_t write_len = 0;
 9703|  15.4k|  for (const auto &x : headers) {
  ------------------
  |  Branch (9703:22): [True: 15.4k, False: 3.31k]
  ------------------
 9704|  15.4k|    std::string s;
 9705|  15.4k|    s = x.first;
 9706|  15.4k|    s += ": ";
 9707|  15.4k|    s += x.second;
 9708|  15.4k|    s += "\r\n";
 9709|       |
 9710|  15.4k|    auto len = strm.write(s.data(), s.size());
 9711|  15.4k|    if (len < 0) { return len; }
  ------------------
  |  Branch (9711:9): [True: 0, False: 15.4k]
  ------------------
 9712|  15.4k|    write_len += len;
 9713|  15.4k|  }
 9714|  3.31k|  auto len = strm.write("\r\n");
 9715|  3.31k|  if (len < 0) { return len; }
  ------------------
  |  Branch (9715:7): [True: 0, False: 3.31k]
  ------------------
 9716|  3.31k|  write_len += len;
 9717|  3.31k|  return write_len;
 9718|  3.31k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1308|  3.31k|  const_iterator begin() const { return make_citer(0, npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10make_citerEmm:
 1441|  87.5k|  const_iterator make_citer(size_type idx, size_type key_idx) const {
 1442|  87.5k|    return const_iterator(entries_.data(), idx, entries_.size(), key_idx);
 1443|  87.5k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEC2EPSF_mmm:
 1283|  87.5k|        : data_(data), idx_(idx), size_(size), key_idx_(key_idx) {}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4nposEv:
 1203|   262k|  static size_type npos() { return static_cast<size_type>(-1); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1309|  78.2k|  const_iterator end() const { return make_citer(entries_.size(), npos()); }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEneISF_EEbRKNSC_IT_EE:
 1274|  61.2k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1275|  61.2k|      return idx_ != rhs.idx_;
 1276|  61.2k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEdeEv:
 1231|  15.4k|    reference operator*() const { return data_[idx_]; }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEppEv:
 1234|  18.2k|    iterator_t &operator++() {
 1235|       |      // Saturating, so that advancing past the last entry of a key stays at
 1236|       |      // end() instead of running off the container.
 1237|  18.2k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1237:11): [True: 0, False: 18.2k]
  ------------------
 1238|  18.2k|      ++idx_;
 1239|  18.2k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1239:11): [True: 2.71k, False: 15.4k]
  ------------------
 1240|  3.37k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1240:16): [True: 2.03k, False: 1.34k]
  |  Branch (1240:32): [True: 659, False: 1.37k]
  ------------------
 1241|    659|          ++idx_;
 1242|    659|        }
 1243|  2.71k|      }
 1244|  18.2k|      return *this;
 1245|  18.2k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEE7matchesEm:
 1285|  2.03k|    bool matches(size_type i) const {
 1286|  2.03k|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1287|  2.03k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10keys_equalERKS8_SD_:
 1205|  90.5k|  static bool keys_equal(const std::string &a, const std::string &b) {
 1206|  90.5k|    return KeyEqual()(a, b);
 1207|  90.5k|  }
_ZNK7httplib6detail11case_ignore8equal_toclERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_:
  735|  90.5k|  bool operator()(const std::string &a, const std::string &b) const {
  736|  90.5k|    return equal(a, b);
  737|  90.5k|  }
_ZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
  718|  90.5k|inline bool equal(const std::string &a, const std::string &b) {
  719|  90.5k|  return a.size() == b.size() &&
  ------------------
  |  Branch (719:10): [True: 12.8k, False: 77.6k]
  ------------------
  720|  12.8k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  ------------------
  |  Branch (720:10): [True: 10.5k, False: 2.28k]
  ------------------
  721|  12.8k|           return to_lower(ca) == to_lower(cb);
  722|  12.8k|         });
  723|  90.5k|}
_ZZN7httplib6detail11case_ignore5equalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_ENKUlccE_clEcc:
  720|   175k|         std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
  721|   175k|           return to_lower(ca) == to_lower(cb);
  722|   175k|         });
_ZN7httplib6detail11case_ignore8to_lowerEi:
  686|   377k|inline unsigned char to_lower(int c) {
  687|   377k|  const static unsigned char table[256] = {
  688|   377k|      0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
  689|   377k|      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
  690|   377k|      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  691|   377k|      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
  692|   377k|      60,  61,  62,  63,  64,  97,  98,  99,  100, 101, 102, 103, 104, 105, 106,
  693|   377k|      107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
  694|   377k|      122, 91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
  695|   377k|      105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  696|   377k|      120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
  697|   377k|      135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
  698|   377k|      150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
  699|   377k|      165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  700|   377k|      180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 224, 225, 226,
  701|   377k|      227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
  702|   377k|      242, 243, 244, 245, 246, 215, 248, 249, 250, 251, 252, 253, 254, 223, 224,
  703|   377k|      225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  704|   377k|      240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
  705|   377k|      255,
  706|   377k|  };
  707|   377k|  return table[(unsigned char)(char)c];
  708|   377k|}
_ZN7httplib6Stream5writeEPKc:
13262|  3.31k|inline ssize_t Stream::write(const char *ptr) {
13263|  3.31k|  return write(ptr, strlen(ptr));
13264|  3.31k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEEC2Ev:
 1299|  3.31k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_9FormFieldENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1299|  3.31k|  insertion_ordered_multimap() = default;
_ZN7httplib6detail26insertion_ordered_multimapINS_8FormDataENSt3__18equal_toINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEEEC2Ev:
 1299|  3.31k|  insertion_ordered_multimap() = default;
_ZN7httplib8ResponseC2Ev:
 1969|  3.31k|  Response() = default;
_ZN7httplib8UserDataC2Ev:
 1495|  3.31k|  UserData() = default;
_ZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorE:
18284|  3.31k|                                        Error &error) {
18285|       |  // Auto-add Expect: 100-continue for large bodies
18286|  3.31k|  if (CPPHTTPLIB_EXPECT_100_THRESHOLD > 0 && !req.has_header("Expect")) {
  ------------------
  |  |   95|  3.31k|#define CPPHTTPLIB_EXPECT_100_THRESHOLD 1024
  ------------------
  |  Branch (18286:7): [True: 3.31k, Folded]
  |  Branch (18286:7): [True: 3.31k, False: 0]
  |  Branch (18286:46): [True: 3.31k, False: 0]
  ------------------
18287|  3.31k|    auto body_size = req.body.empty() ? req.content_length_ : req.body.size();
  ------------------
  |  Branch (18287:22): [True: 3.31k, False: 0]
  ------------------
18288|  3.31k|    if (body_size >= CPPHTTPLIB_EXPECT_100_THRESHOLD) {
  ------------------
  |  |   95|  3.31k|#define CPPHTTPLIB_EXPECT_100_THRESHOLD 1024
  ------------------
  |  Branch (18288:9): [True: 0, False: 3.31k]
  ------------------
18289|      0|      req.set_header("Expect", "100-continue");
18290|      0|    }
18291|  3.31k|  }
18292|       |
18293|       |  // Check for Expect: 100-continue
18294|  3.31k|  auto expect_100_continue =
18295|  3.31k|      detail::has_header_token(req.headers, "Expect", "100-continue");
18296|       |
18297|       |  // Send request (skip body if using Expect: 100-continue)
18298|  3.31k|  auto rejected_locally = false;
18299|  3.31k|  auto write_request_success =
18300|  3.31k|      write_request(strm, req, close_connection, error, expect_100_continue,
18301|  3.31k|                    rejected_locally);
18302|       |
18303|       |  // A failed write normally still reads the response below, since the server
18304|       |  // may have answered early (e.g. 413/414) and closed while the body was being
18305|       |  // sent. A request rejected before any byte reached the socket gets no such
18306|       |  // response, and waiting for one would block until the read timeout.
18307|  3.31k|  if (rejected_locally) { return false; }
  ------------------
  |  Branch (18307:7): [True: 0, False: 3.31k]
  ------------------
18308|       |
18309|       |#ifdef CPPHTTPLIB_SSL_ENABLED
18310|       |  if (is_ssl() && !expect_100_continue) {
18311|       |    auto is_proxy_enabled = is_proxy_enabled_for_host(host_);
18312|       |    if (!is_proxy_enabled) {
18313|       |      if (tls::is_peer_closed(socket_.ssl, socket_.sock)) {
18314|       |        error = Error::SSLPeerCouldBeClosed_;
18315|       |        return false;
18316|       |      }
18317|       |    }
18318|       |  }
18319|       |#endif
18320|       |
18321|       |  // Handle Expect: 100-continue.
18322|       |  //
18323|       |  // Wait for an interim/early response by attempting to read the status line
18324|       |  // under a short timeout, instead of trusting raw socket readability. Over
18325|       |  // TLS, post-handshake records (e.g. session tickets) make the socket
18326|       |  // readable without any HTTP response being available; relying on
18327|       |  // `select_read` there caused the body to be withheld forever and the
18328|       |  // request to fail with `Read` (#2458). If no status line arrives within the
18329|       |  // timeout, send the body anyway (matching curl's behavior).
18330|  3.31k|  auto status_line_read = false;
18331|  3.31k|  if (expect_100_continue && write_request_success) {
  ------------------
  |  Branch (18331:7): [True: 0, False: 3.31k]
  |  Branch (18331:30): [True: 0, False: 0]
  ------------------
18332|      0|    if (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND > 0) {
  ------------------
  |  |   99|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
  |  Branch (18332:9): [True: 0, Folded]
  ------------------
18333|      0|      time_t sec = CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND / 1000;
  ------------------
  |  |   99|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
18334|      0|      time_t usec = (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND % 1000) * 1000;
  ------------------
  |  |   99|      0|#define CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND 1000
  ------------------
18335|      0|      strm.set_read_timeout(sec, usec);
18336|      0|      status_line_read = read_response_line(strm, req, res, false);
18337|      0|      strm.set_read_timeout(read_timeout_sec_, read_timeout_usec_);
18338|      0|    }
18339|       |
18340|      0|    if (!status_line_read) {
  ------------------
  |  Branch (18340:9): [True: 0, False: 0]
  ------------------
18341|       |      // No interim response within the timeout: send the body and handle the
18342|       |      // response as usual.
18343|      0|      if (!write_request_body(strm, req, error)) { return false; }
  ------------------
  |  Branch (18343:11): [True: 0, False: 0]
  ------------------
18344|      0|      expect_100_continue = false; // Switch to normal response handling
18345|      0|    }
18346|      0|  }
18347|       |
18348|       |  // Receive response and headers
18349|       |  // When using Expect: 100-continue, don't auto-skip `100 Continue` response
18350|  3.31k|  if ((!status_line_read &&
  ------------------
  |  Branch (18350:8): [True: 3.31k, False: 0]
  ------------------
18351|  3.31k|       !read_response_line(strm, req, res, !expect_100_continue)) ||
  ------------------
  |  Branch (18351:8): [True: 612, False: 2.70k]
  ------------------
18352|  2.70k|      !detail::read_headers(strm, res.headers)) {
  ------------------
  |  Branch (18352:7): [True: 692, False: 2.01k]
  ------------------
18353|  1.30k|    if (write_request_success) { error = Error::Read; }
  ------------------
  |  Branch (18353:9): [True: 1.30k, False: 0]
  ------------------
18354|  1.30k|    return false;
18355|  1.30k|  }
18356|       |
18357|  2.01k|  if (!write_request_success) { return false; }
  ------------------
  |  Branch (18357:7): [True: 0, False: 2.01k]
  ------------------
18358|       |
18359|       |  // Handle Expect: 100-continue response
18360|  2.01k|  if (expect_100_continue) {
  ------------------
  |  Branch (18360:7): [True: 0, False: 2.01k]
  ------------------
18361|      0|    if (res.status == StatusCode::Continue_100) {
  ------------------
  |  Branch (18361:9): [True: 0, False: 0]
  ------------------
18362|       |      // Server accepted, send the body
18363|      0|      if (!write_request_body(strm, req, error)) { return false; }
  ------------------
  |  Branch (18363:11): [True: 0, False: 0]
  ------------------
18364|       |
18365|       |      // Read the actual response
18366|      0|      res.headers.clear();
18367|      0|      res.body.clear();
18368|      0|      if (!read_response_line(strm, req, res) ||
  ------------------
  |  Branch (18368:11): [True: 0, False: 0]
  ------------------
18369|      0|          !detail::read_headers(strm, res.headers)) {
  ------------------
  |  Branch (18369:11): [True: 0, False: 0]
  ------------------
18370|      0|        error = Error::Read;
18371|      0|        return false;
18372|      0|      }
18373|      0|    } else {
18374|       |      // A final response came first, so the body this request declared was
18375|       |      // never sent, and the server may still be waiting for it. The
18376|       |      // connection cannot carry another request.
18377|      0|      std::lock_guard<std::mutex> guard(socket_mutex_);
18378|      0|      socket_should_be_closed_when_request_is_done_ = true;
18379|      0|    }
18380|      0|  }
18381|       |
18382|       |  // Body
18383|  2.01k|  if ((res.status != StatusCode::NoContent_204) && req.method != "HEAD" &&
  ------------------
  |  Branch (18383:7): [True: 2.00k, False: 6]
  |  Branch (18383:52): [True: 2.00k, False: 0]
  ------------------
18384|  2.00k|      req.method != "CONNECT") {
  ------------------
  |  Branch (18384:7): [True: 2.00k, False: 0]
  ------------------
18385|       |    // Reject ambiguous framing (RFC 9112 §6.3). Unlike a request, a response
18386|       |    // whose final transfer coding is not chunked is not ambiguous: its body
18387|       |    // runs until the server closes the connection, so it is not rejected.
18388|       |    // HEAD/204 are excluded above and a 304 carries no body.
18389|  2.00k|    if (res.status != StatusCode::NotModified_304) {
  ------------------
  |  Branch (18389:9): [True: 1.99k, False: 10]
  ------------------
18390|  1.99k|      if (detail::has_conflicting_content_length(res.headers)) {
  ------------------
  |  Branch (18390:11): [True: 118, False: 1.88k]
  ------------------
18391|    118|        error = Error::Read;
18392|    118|        return false;
18393|    118|      }
18394|  1.88k|      if (detail::has_faulty_transfer_encoding(res)) {
  ------------------
  |  Branch (18394:11): [True: 576, False: 1.30k]
  ------------------
18395|    576|        std::lock_guard<std::mutex> guard(socket_mutex_);
18396|    576|        socket_should_be_closed_when_request_is_done_ = true;
18397|    576|      }
18398|  1.88k|    }
18399|       |
18400|  1.89k|    auto redirect = follow_location_ && detail::is_redirect(res);
  ------------------
  |  Branch (18400:21): [True: 0, False: 1.89k]
  |  Branch (18400:41): [True: 0, False: 0]
  ------------------
18401|       |
18402|  1.89k|    if (req.response_handler && !redirect) {
  ------------------
  |  Branch (18402:9): [True: 0, False: 1.89k]
  |  Branch (18402:33): [True: 0, False: 0]
  ------------------
18403|      0|      if (!req.response_handler(res)) {
  ------------------
  |  Branch (18403:11): [True: 0, False: 0]
  ------------------
18404|      0|        error = Error::Canceled;
18405|      0|        return false;
18406|      0|      }
18407|      0|    }
18408|       |
18409|  1.89k|    auto out =
18410|  1.89k|        req.content_receiver
  ------------------
  |  Branch (18410:9): [True: 0, False: 1.89k]
  ------------------
18411|  1.89k|            ? static_cast<ContentReceiverWithProgress>(
18412|      0|                  [&](const char *buf, size_t n, size_t off, size_t len) {
18413|      0|                    if (redirect) { return true; }
18414|      0|                    auto ret = req.content_receiver(buf, n, off, len);
18415|      0|                    if (!ret) { error = Error::Canceled; }
18416|      0|                    return ret;
18417|      0|                  })
18418|  1.89k|            : static_cast<ContentReceiverWithProgress>(
18419|  1.89k|                  [&](const char *buf, size_t n, size_t /*off*/,
18420|  1.89k|                      size_t /*len*/) {
18421|  1.89k|                    assert(res.body.size() + n <= res.body.max_size());
18422|  1.89k|                    if (payload_max_length_ > 0 &&
18423|  1.89k|                        (res.body.size() >= payload_max_length_ ||
18424|  1.89k|                         n > payload_max_length_ - res.body.size())) {
18425|  1.89k|                      return false;
18426|  1.89k|                    }
18427|  1.89k|                    res.body.append(buf, n);
18428|  1.89k|                    return true;
18429|  1.89k|                  });
18430|       |
18431|  1.89k|    auto progress = [&](size_t current, size_t total) {
18432|  1.89k|      if (!req.download_progress || redirect) { return true; }
18433|  1.89k|      auto ret = req.download_progress(current, total);
18434|  1.89k|      if (!ret) { error = Error::Canceled; }
18435|  1.89k|      return ret;
18436|  1.89k|    };
18437|       |
18438|  1.89k|    if (res.has_header("Content-Length")) {
  ------------------
  |  Branch (18438:9): [True: 572, False: 1.31k]
  ------------------
18439|    572|      if (!req.content_receiver) {
  ------------------
  |  Branch (18439:11): [True: 572, False: 0]
  ------------------
18440|    572|        auto len = res.get_header_value_u64("Content-Length");
18441|    572|        if (len > res.body.max_size()) {
  ------------------
  |  Branch (18441:13): [True: 61, False: 511]
  ------------------
18442|     61|          error = Error::Read;
18443|     61|          return false;
18444|     61|        }
18445|       |        // Content-Length is only the server's claim, so reserve no more than
18446|       |        // payload_max_length_ allows, nor more than 1 MiB before any of the
18447|       |        // body has arrived. A longer body grows as it is read.
18448|    511|        auto reserve_len =
18449|    511|            (std::min)(static_cast<size_t>(len), size_t(1024 * 1024));
18450|    511|        if (payload_max_length_ > 0) {
  ------------------
  |  Branch (18450:13): [True: 511, False: 0]
  ------------------
18451|    511|          reserve_len = (std::min)(reserve_len, payload_max_length_);
18452|    511|        }
18453|    511|        res.body.reserve(reserve_len);
18454|    511|      }
18455|    572|    }
18456|       |
18457|  1.83k|    if (res.status != StatusCode::NotModified_304) {
  ------------------
  |  Branch (18457:9): [True: 1.82k, False: 10]
  ------------------
18458|  1.82k|      auto content_status = 0;
18459|  1.82k|      auto max_length = (!has_payload_max_length_ && req.content_receiver)
  ------------------
  |  Branch (18459:26): [True: 1.82k, False: 0]
  |  Branch (18459:54): [True: 0, False: 1.82k]
  ------------------
18460|  1.82k|                            ? (std::numeric_limits<size_t>::max)()
18461|  1.82k|                            : payload_max_length_;
18462|  1.82k|      if (!detail::read_content(strm, res, max_length, content_status,
  ------------------
  |  Branch (18462:11): [True: 1.31k, False: 509]
  ------------------
18463|  1.82k|                                std::move(progress), std::move(out),
18464|  1.82k|                                decompress_)) {
18465|  1.31k|        if (error != Error::Canceled) {
  ------------------
  |  Branch (18465:13): [True: 1.31k, False: 0]
  ------------------
18466|       |          // Tell the caller apart from a plain read failure when the body was
18467|       |          // over the payload limit or could not be decoded because of its
18468|       |          // Content-Encoding.
18469|  1.31k|          switch (content_status) {
18470|     14|          case StatusCode::PayloadTooLarge_413:
  ------------------
  |  Branch (18470:11): [True: 14, False: 1.29k]
  ------------------
18471|     14|            error = Error::ExceedMaxPayloadSize;
18472|     14|            break;
18473|      2|          case StatusCode::UnsupportedMediaType_415:
  ------------------
  |  Branch (18473:11): [True: 2, False: 1.30k]
  ------------------
18474|      2|            error = Error::UnsupportedContentEncoding;
18475|      2|            break;
18476|      0|          case StatusCode::InternalServerError_500:
  ------------------
  |  Branch (18476:11): [True: 0, False: 1.31k]
  ------------------
18477|      0|            error = Error::Compression;
18478|      0|            break;
18479|  1.29k|          default: error = Error::Read; break;
  ------------------
  |  Branch (18479:11): [True: 1.29k, False: 16]
  ------------------
18480|  1.31k|          }
18481|  1.31k|        }
18482|  1.31k|        return false;
18483|  1.31k|      }
18484|  1.82k|    }
18485|  1.83k|  }
18486|       |
18487|       |  // Log
18488|    525|  output_log(req, res);
18489|       |
18490|    525|  return true;
18491|  2.01k|}
_ZNK7httplib7Request10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
12875|  23.2k|inline bool Request::has_header(const std::string &key) const {
12876|  23.2k|  return detail::has_header(headers, key);
12877|  23.2k|}
_ZN7httplib6detail10has_headerERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 9134|  26.2k|inline bool has_header(const Headers &headers, const std::string &key) {
 9135|  26.2k|  if (is_prohibited_header_name(key)) { return false; }
  ------------------
  |  Branch (9135:7): [True: 0, False: 26.2k]
  ------------------
 9136|  26.2k|  return headers.find(key) != headers.end();
 9137|  26.2k|}
_ZN7httplib6detail25is_prohibited_header_nameERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9126|  26.2k|inline bool is_prohibited_header_name(const std::string &name) {
 9127|       |  // Field names are case-insensitive (RFC 9110 §5.1)
 9128|  26.2k|  return case_ignore::equal(name, "REMOTE_ADDR") ||
  ------------------
  |  Branch (9128:10): [True: 0, False: 26.2k]
  ------------------
 9129|  26.2k|         case_ignore::equal(name, "REMOTE_PORT") ||
  ------------------
  |  Branch (9129:10): [True: 0, False: 26.2k]
  ------------------
 9130|  26.2k|         case_ignore::equal(name, "LOCAL_ADDR") ||
  ------------------
  |  Branch (9130:10): [True: 0, False: 26.2k]
  ------------------
 9131|  26.2k|         case_ignore::equal(name, "LOCAL_PORT");
  ------------------
  |  Branch (9131:10): [True: 0, False: 26.2k]
  ------------------
 9132|  26.2k|}
_ZN7httplib6detail11case_ignore5equalILm12EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  52.5k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  52.5k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 0, False: 52.5k]
  ------------------
  729|      0|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 0, False: 0]
  ------------------
  730|      0|           return to_lower(ca) == to_lower(cb);
  731|      0|         });
  732|  52.5k|}
_ZN7httplib6detail11case_ignore5equalILm11EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  52.5k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  52.5k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 6.63k, False: 45.8k]
  ------------------
  729|  6.63k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 0, False: 6.63k]
  ------------------
  730|  6.63k|           return to_lower(ca) == to_lower(cb);
  731|  6.63k|         });
  732|  52.5k|}
_ZZN7httplib6detail11case_ignore5equalILm11EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  6.63k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  6.63k|           return to_lower(ca) == to_lower(cb);
  731|  6.63k|         });
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE4findERKS8_:
 1345|  31.0k|  const_iterator find(const std::string &key) const {
 1346|  31.0k|    auto i = index_of(key);
 1347|  31.0k|    return i == npos() ? end() : make_citer(i, i);
  ------------------
  |  Branch (1347:12): [True: 27.7k, False: 3.36k]
  ------------------
 1348|  31.0k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE8index_ofERKS8_:
 1430|  45.6k|  size_type index_of(const std::string &key) const {
 1431|   124k|    for (size_type i = 0; i < entries_.size(); i++) {
  ------------------
  |  Branch (1431:27): [True: 85.5k, False: 38.6k]
  ------------------
 1432|  85.5k|      if (keys_equal(entries_[i].first, key)) { return i; }
  ------------------
  |  Branch (1432:11): [True: 7.00k, False: 78.5k]
  ------------------
 1433|  85.5k|    }
 1434|  38.6k|    return npos();
 1435|  45.6k|  }
_ZN7httplib7Request10set_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_:
12889|  8.85k|                                const std::string &val) {
12890|  8.85k|  detail::set_header(headers, key, val);
12891|  8.85k|}
_ZN7httplib6detail10set_headerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_SE_:
 9211|  8.85k|                       const std::string &val) {
 9212|  8.85k|  if (fields::is_field_valid(key, val)) { headers.emplace(key, val); }
  ------------------
  |  Branch (9212:7): [True: 8.85k, False: 0]
  ------------------
 9213|  8.85k|}
_ZN7httplib6detail6fields14is_field_validERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_:
11305|  24.3k|inline bool is_field_valid(const std::string &name, const std::string &value) {
11306|  24.3k|  return is_field_name(name) && is_field_value(value);
  ------------------
  |  Branch (11306:10): [True: 24.3k, False: 0]
  |  Branch (11306:33): [True: 24.3k, False: 0]
  ------------------
11307|  24.3k|}
_ZN7httplib6detail6fields13is_field_nameERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11270|  47.7k|inline bool is_field_name(const std::string &s) { return is_token(s); }
_ZN7httplib6detail6fields8is_tokenERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11262|  51.0k|inline bool is_token(const std::string &s) {
11263|  51.0k|  if (s.empty()) { return false; }
  ------------------
  |  Branch (11263:7): [True: 74, False: 50.9k]
  ------------------
11264|   474k|  for (auto c : s) {
  ------------------
  |  Branch (11264:15): [True: 474k, False: 50.7k]
  ------------------
11265|   474k|    if (!is_token_char(c)) { return false; }
  ------------------
  |  Branch (11265:9): [True: 160, False: 474k]
  ------------------
11266|   474k|  }
11267|  50.7k|  return true;
11268|  50.9k|}
_ZN7httplib6detail6fields13is_token_charEc:
11256|   474k|inline bool is_token_char(char c) {
11257|   474k|  return is_ascii_alnum(c) || c == '!' || c == '#' || c == '$' || c == '%' ||
  ------------------
  |  Branch (11257:10): [True: 432k, False: 41.9k]
  |  Branch (11257:31): [True: 1.06k, False: 40.8k]
  |  Branch (11257:43): [True: 1.64k, False: 39.2k]
  |  Branch (11257:55): [True: 557, False: 38.6k]
  |  Branch (11257:67): [True: 821, False: 37.8k]
  ------------------
11258|  37.8k|         c == '&' || c == '\'' || c == '*' || c == '+' || c == '-' ||
  ------------------
  |  Branch (11258:10): [True: 1.06k, False: 36.7k]
  |  Branch (11258:22): [True: 569, False: 36.2k]
  |  Branch (11258:35): [True: 1.29k, False: 34.9k]
  |  Branch (11258:47): [True: 1.09k, False: 33.8k]
  |  Branch (11258:59): [True: 25.6k, False: 8.17k]
  ------------------
11259|  8.17k|         c == '.' || c == '^' || c == '_' || c == '`' || c == '|' || c == '~';
  ------------------
  |  Branch (11259:10): [True: 810, False: 7.36k]
  |  Branch (11259:22): [True: 2.27k, False: 5.08k]
  |  Branch (11259:34): [True: 2.67k, False: 2.41k]
  |  Branch (11259:46): [True: 395, False: 2.02k]
  |  Branch (11259:58): [True: 364, False: 1.65k]
  |  Branch (11259:70): [True: 1.49k, False: 160]
  ------------------
11260|   474k|}
_ZN7httplib6detail14is_ascii_alnumEc:
  680|   474k|inline bool is_ascii_alnum(char c) {
  681|   474k|  return is_ascii_digit(c) || is_ascii_alpha(c);
  ------------------
  |  Branch (681:10): [True: 20.1k, False: 454k]
  |  Branch (681:31): [True: 412k, False: 41.9k]
  ------------------
  682|   474k|}
_ZN7httplib6detail14is_ascii_digitEc:
  674|   537k|inline bool is_ascii_digit(char c) { return '0' <= c && c <= '9'; }
  ------------------
  |  Branch (674:45): [True: 502k, False: 35.0k]
  |  Branch (674:57): [True: 79.0k, False: 423k]
  ------------------
_ZN7httplib6detail14is_ascii_alphaEc:
  676|   454k|inline bool is_ascii_alpha(char c) {
  677|   454k|  return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
  ------------------
  |  Branch (677:11): [True: 326k, False: 127k]
  |  Branch (677:23): [True: 324k, False: 1.86k]
  |  Branch (677:37): [True: 94.3k, False: 34.7k]
  |  Branch (677:49): [True: 87.1k, False: 7.21k]
  ------------------
  678|   454k|}
_ZN7httplib6detail6fields14is_field_valueERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11303|  47.2k|inline bool is_field_value(const std::string &s) { return is_field_content(s); }
_ZN7httplib6detail6fields16is_field_contentERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11278|  47.2k|inline bool is_field_content(const std::string &s) {
11279|  47.2k|  if (s.empty()) { return true; }
  ------------------
  |  Branch (11279:7): [True: 17.4k, False: 29.7k]
  ------------------
11280|       |
11281|  29.7k|  if (s.size() == 1) {
  ------------------
  |  Branch (11281:7): [True: 5.32k, False: 24.4k]
  ------------------
11282|  5.32k|    return is_field_vchar(s[0]);
11283|  24.4k|  } else if (s.size() == 2) {
  ------------------
  |  Branch (11283:14): [True: 327, False: 24.1k]
  ------------------
11284|    327|    return is_field_vchar(s[0]) && is_field_vchar(s[1]);
  ------------------
  |  Branch (11284:12): [True: 326, False: 1]
  |  Branch (11284:36): [True: 325, False: 1]
  ------------------
11285|  24.1k|  } else {
11286|  24.1k|    size_t i = 0;
11287|       |
11288|  24.1k|    if (!is_field_vchar(s[i])) { return false; }
  ------------------
  |  Branch (11288:9): [True: 2, False: 24.1k]
  ------------------
11289|  24.1k|    i++;
11290|       |
11291|  2.51M|    while (i < s.size() - 1) {
  ------------------
  |  Branch (11291:12): [True: 2.49M, False: 24.0k]
  ------------------
11292|  2.49M|      auto c = s[i++];
11293|  2.49M|      if (c == ' ' || c == '\t' || is_field_vchar(c)) {
  ------------------
  |  Branch (11293:11): [True: 17.2k, False: 2.47M]
  |  Branch (11293:23): [True: 1.27k, False: 2.47M]
  |  Branch (11293:36): [True: 2.47M, False: 39]
  ------------------
11294|  2.49M|      } else {
11295|     39|        return false;
11296|     39|      }
11297|  2.49M|    }
11298|       |
11299|  24.0k|    return is_field_vchar(s[i]);
11300|  24.1k|  }
11301|  29.7k|}
_ZN7httplib6detail6fields14is_field_vcharEc:
11276|  2.72M|inline bool is_field_vchar(char c) { return is_vchar(c) || is_obs_text(c); }
  ------------------
  |  Branch (11276:45): [True: 1.36M, False: 1.36M]
  |  Branch (11276:60): [True: 1.36M, False: 86]
  ------------------
_ZN7httplib6detail6fields8is_vcharEc:
11272|  2.72M|inline bool is_vchar(char c) { return c >= 33 && c <= 126; }
  ------------------
  |  Branch (11272:39): [True: 1.36M, False: 1.36M]
  |  Branch (11272:50): [True: 1.36M, False: 1]
  ------------------
_ZN7httplib6detail6fields11is_obs_textEc:
11274|  1.36M|inline bool is_obs_text(char c) { return 128 <= static_cast<unsigned char>(c); }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE7emplaceIJRKS8_SE_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1328|  30.5k|  template <typename... Args> iterator emplace(Args &&...args) {
 1329|  30.5k|    entries_.emplace_back(std::forward<Args>(args)...);
 1330|  30.5k|    return make_iter(entries_.size() - 1, npos());
 1331|  30.5k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE9make_iterEmm:
 1437|  60.8k|  iterator make_iter(size_type idx, size_type key_idx) {
 1438|  60.8k|    return iterator(entries_.data(), idx, entries_.size(), key_idx);
 1439|  60.8k|  }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEC2EPSE_mmm:
 1283|  60.8k|        : 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_:
 9183|  3.31k|                             const std::string &token) {
 9184|       |  // RFC 9110 7.6.1: a comma-separated token list field such as Connection may
 9185|       |  // carry several tokens, and RFC 9110 5.3 lets that list be split across
 9186|       |  // several lines. Match complete tokens rather than searching the raw value,
 9187|       |  // so that a value such as "notupgrade" is not read as the token "upgrade".
 9188|  3.31k|  auto rng = headers.equal_range(key);
 9189|  3.31k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9189:29): [True: 0, False: 3.31k]
  ------------------
 9190|      0|    const auto &value = it->second;
 9191|      0|    if (split_find(value.data(), value.data() + value.size(), ',',
  ------------------
  |  Branch (9191:9): [True: 0, False: 0]
  ------------------
 9192|      0|                   [&](const char *b, const char *e) {
 9193|      0|                     return case_ignore::equal(std::string(b, e), token);
 9194|      0|                   })) {
 9195|      0|      return true;
 9196|      0|    }
 9197|      0|  }
 9198|  3.31k|  return false;
 9199|  3.31k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1365|  9.36k|  equal_range(const std::string &key) const {
 1366|  9.36k|    auto i = index_of(key);
 1367|  9.36k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1367:12): [True: 6.77k, False: 2.59k]
  ------------------
 1368|  9.36k|                       : std::make_pair(make_citer(i, i), end());
 1369|  9.36k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEptEv:
 1232|  6.12k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail4trimEPKcS2_mm:
 6672|  25.4k|                                      size_t right) {
 6673|  33.8k|  while (b + left < e && is_space_or_tab(b[left])) {
  ------------------
  |  Branch (6673:10): [True: 33.6k, False: 138]
  |  Branch (6673:26): [True: 8.40k, False: 25.2k]
  ------------------
 6674|  8.40k|    left++;
 6675|  8.40k|  }
 6676|  33.8k|  while (right > 0 && is_space_or_tab(b[right - 1])) {
  ------------------
  |  Branch (6676:10): [True: 33.6k, False: 178]
  |  Branch (6676:23): [True: 8.41k, False: 25.2k]
  ------------------
 6677|  8.41k|    right--;
 6678|  8.41k|  }
 6679|  25.4k|  return std::make_pair(left, right);
 6680|  25.4k|}
_ZN7httplib6detail15is_space_or_tabEc:
 6525|   308k|inline bool is_space_or_tab(char c) { return c == ' ' || c == '\t'; }
  ------------------
  |  Branch (6525:46): [True: 28.3k, False: 280k]
  |  Branch (6525:58): [True: 1.16k, False: 279k]
  ------------------
_ZN7httplib10ClientImpl13write_requestERNS_6StreamERNS_7RequestEbRNS_5ErrorEbRb:
17966|  3.31k|                                      bool skip_body, bool &rejected_locally) {
17967|  3.31k|  rejected_locally = false;
17968|       |
17969|       |  // Prepare additional headers
17970|  3.31k|  if (close_connection) {
  ------------------
  |  Branch (17970:7): [True: 0, False: 3.31k]
  ------------------
17971|      0|    if (!req.has_header("Connection")) {
  ------------------
  |  Branch (17971:9): [True: 0, False: 0]
  ------------------
17972|      0|      req.set_header("Connection", "close");
17973|      0|    }
17974|      0|  }
17975|       |
17976|  3.31k|  std::string ct_for_defaults;
17977|  3.31k|  if (!req.has_header("Content-Type") && !req.body.empty()) {
  ------------------
  |  Branch (17977:7): [True: 3.31k, False: 0]
  |  Branch (17977:7): [True: 0, False: 3.31k]
  |  Branch (17977:42): [True: 0, False: 3.31k]
  ------------------
17978|      0|    ct_for_defaults = "text/plain";
17979|      0|  }
17980|  3.31k|  prepare_default_headers(req, false, ct_for_defaults);
17981|       |
17982|  3.31k|  if (req.body.empty()) {
  ------------------
  |  Branch (17982:7): [True: 3.31k, False: 0]
  ------------------
17983|  3.31k|    if (req.content_provider_) {
  ------------------
  |  Branch (17983:9): [True: 0, False: 3.31k]
  ------------------
17984|      0|      if (!req.is_chunked_content_provider_) {
  ------------------
  |  Branch (17984:11): [True: 0, False: 0]
  ------------------
17985|      0|        if (!req.has_header("Content-Length")) {
  ------------------
  |  Branch (17985:13): [True: 0, False: 0]
  ------------------
17986|      0|          auto length = std::to_string(req.content_length_);
17987|      0|          req.set_header("Content-Length", length);
17988|      0|        }
17989|      0|      }
17990|  3.31k|    } else {
17991|  3.31k|      if (req.method == "POST" || req.method == "PUT" ||
  ------------------
  |  Branch (17991:11): [True: 565, False: 2.75k]
  |  Branch (17991:35): [True: 1.16k, False: 1.58k]
  ------------------
17992|  2.21k|          req.method == "PATCH") {
  ------------------
  |  Branch (17992:11): [True: 483, False: 1.10k]
  ------------------
17993|  2.21k|        req.set_header("Content-Length", "0");
17994|  2.21k|      }
17995|  3.31k|    }
17996|  3.31k|  }
17997|       |
17998|  3.31k|  add_credential_headers(req);
17999|       |
18000|       |  // Request line and headers
18001|  3.31k|  {
18002|  3.31k|    detail::BufferStream bstrm;
18003|       |
18004|  3.31k|    auto path_with_query = make_request_target(req);
18005|       |
18006|       |    // The query already came in through `req.path`; still populate
18007|       |    // `req.params` for handlers/users who read them.
18008|  3.31k|    auto query_part = detail::query_of(req.path);
18009|  3.31k|    if (!query_part.empty()) {
  ------------------
  |  Branch (18009:9): [True: 0, False: 3.31k]
  ------------------
18010|      0|      detail::parse_query_text(query_part, req.params);
18011|      0|    }
18012|       |
18013|       |    // Write request line and headers
18014|  3.31k|    if (detail::write_request_line(bstrm, req.method, path_with_query) < 0) {
  ------------------
  |  Branch (18014:9): [True: 0, False: 3.31k]
  ------------------
18015|       |      // A rejected method (not a token, e.g. carrying CR/LF) or target (e.g.
18016|       |      // CR/LF in a caller-supplied path under set_path_encode(false)) must
18017|       |      // fail the request cleanly instead of emitting a request-line-less,
18018|       |      // header-injecting request.
18019|      0|      error = Error::Write;
18020|      0|      rejected_locally = true;
18021|      0|      return false;
18022|      0|    }
18023|  3.31k|    if (!detail::check_and_write_headers(bstrm, req.headers, header_writer_,
  ------------------
  |  Branch (18023:9): [True: 0, False: 3.31k]
  ------------------
18024|  3.31k|                                         error)) {
18025|      0|      rejected_locally = true;
18026|      0|      return false;
18027|      0|    }
18028|       |
18029|       |    // Flush buffer
18030|  3.31k|    auto &data = bstrm.get_buffer();
18031|  3.31k|    if (!detail::write_data(strm, data.data(), data.size())) {
  ------------------
  |  Branch (18031:9): [True: 0, False: 3.31k]
  ------------------
18032|      0|      error = Error::Write;
18033|      0|      return false;
18034|      0|    }
18035|  3.31k|  }
18036|       |
18037|       |  // After sending request line and headers, wait briefly for an early server
18038|       |  // response (e.g. 4xx) and avoid sending a potentially large request body
18039|       |  // unnecessarily. This workaround is only enabled on Windows because Unix
18040|       |  // platforms surface write errors (EPIPE) earlier; on Windows kernel send
18041|       |  // buffering can accept large writes even when the peer already responded.
18042|       |  // Check the stream first (which covers SSL via `is_readable()`), then
18043|       |  // fall back to select on the socket. Only perform the wait for very large
18044|       |  // request bodies to avoid interfering with normal small requests and
18045|       |  // reduce side-effects. Poll briefly (up to 50ms as default) for an early
18046|       |  // response. Skip this check when using Expect: 100-continue, as the protocol
18047|       |  // handles early responses properly.
18048|       |#if defined(_WIN32)
18049|       |  if (!skip_body &&
18050|       |      req.body.size() > CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_THRESHOLD &&
18051|       |      req.path.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
18052|       |    auto start = std::chrono::high_resolution_clock::now();
18053|       |
18054|       |    for (;;) {
18055|       |      // Prefer socket-level readiness to avoid SSL_pending() false-positives
18056|       |      // from SSL internals. If the underlying socket is readable, assume an
18057|       |      // early response may be present.
18058|       |      auto sock = strm.socket();
18059|       |      if (sock != INVALID_SOCKET && detail::select_read(sock, 0, 0) > 0) {
18060|       |        return false;
18061|       |      }
18062|       |
18063|       |      // Fallback to stream-level check for non-socket streams or when the
18064|       |      // socket isn't reporting readable. Avoid using `is_readable()` for
18065|       |      // SSL, since `SSL_pending()` may report buffered records that do not
18066|       |      // indicate a complete application-level response yet.
18067|       |      if (!is_ssl() && strm.is_readable()) { return false; }
18068|       |
18069|       |      auto now = std::chrono::high_resolution_clock::now();
18070|       |      auto elapsed =
18071|       |          std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
18072|       |              .count();
18073|       |      if (elapsed >= CPPHTTPLIB_WAIT_EARLY_SERVER_RESPONSE_TIMEOUT_MSECOND) {
18074|       |        break;
18075|       |      }
18076|       |
18077|       |      std::this_thread::sleep_for(std::chrono::milliseconds(1));
18078|       |    }
18079|       |  }
18080|       |#endif
18081|       |
18082|       |  // Body
18083|  3.31k|  if (skip_body) { return true; }
  ------------------
  |  Branch (18083:7): [True: 0, False: 3.31k]
  ------------------
18084|       |
18085|  3.31k|  return write_request_body(strm, req, error);
18086|  3.31k|}
_ZN7httplib10ClientImpl23prepare_default_headersERNS_7RequestEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
17155|  3.31k|                                                const std::string &ct) {
17156|  3.31k|  (void)for_stream;
17157|       |  // Default headers are meant for the origin and may carry its credentials, so
17158|       |  // keep them off the CONNECT request the proxy reads.
17159|  3.31k|  if (r.method != "CONNECT") {
  ------------------
  |  Branch (17159:7): [True: 3.31k, False: 0]
  ------------------
17160|  3.31k|    for (const auto &header : default_headers_) {
  ------------------
  |  Branch (17160:29): [True: 0, False: 3.31k]
  ------------------
17161|      0|      if (!r.has_header(header.first)) { r.headers.insert(header); }
  ------------------
  |  Branch (17161:11): [True: 0, False: 0]
  ------------------
17162|      0|    }
17163|  3.31k|  }
17164|       |
17165|       |  // RFC 9110 5.3 recommends sending control data such as Host first, so
17166|       |  // prepend it rather than appending it after the caller's own fields.
17167|  3.31k|  if (!r.has_header("Host")) {
  ------------------
  |  Branch (17167:7): [True: 3.31k, False: 0]
  ------------------
17168|  3.31k|    r.headers.emplace_front(
17169|  3.31k|        "Host", detail::make_default_host_header_value(host_, port_, is_ssl(),
17170|  3.31k|                                                       address_family_));
17171|  3.31k|  }
17172|       |
17173|  3.31k|  if (!r.has_header("Accept")) { r.headers.emplace("Accept", "*/*"); }
  ------------------
  |  Branch (17173:7): [True: 3.31k, False: 0]
  ------------------
17174|       |
17175|  3.31k|  if (!r.content_receiver) {
  ------------------
  |  Branch (17175:7): [True: 3.31k, False: 0]
  ------------------
17176|  3.31k|    if (!r.has_header("Accept-Encoding")) {
  ------------------
  |  Branch (17176:9): [True: 3.31k, False: 0]
  ------------------
17177|  3.31k|      std::string accept_encoding;
17178|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
17179|       |      accept_encoding = "br";
17180|       |#endif
17181|  3.31k|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
17182|  3.31k|      if (!accept_encoding.empty()) { accept_encoding += ", "; }
  ------------------
  |  Branch (17182:11): [True: 0, False: 3.31k]
  ------------------
17183|  3.31k|      accept_encoding += "gzip, deflate";
17184|  3.31k|#endif
17185|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
17186|       |      if (!accept_encoding.empty()) { accept_encoding += ", "; }
17187|       |      accept_encoding += "zstd";
17188|       |#endif
17189|  3.31k|      r.set_header("Accept-Encoding", accept_encoding);
17190|  3.31k|    }
17191|       |
17192|  3.31k|    detail::add_default_user_agent_header(r);
17193|  3.31k|  }
17194|       |
17195|  3.31k|  if (!r.body.empty()) {
  ------------------
  |  Branch (17195:7): [True: 0, False: 3.31k]
  ------------------
17196|      0|    if (!ct.empty() && !r.has_header("Content-Type")) {
  ------------------
  |  Branch (17196:9): [True: 0, False: 0]
  |  Branch (17196:9): [True: 0, False: 0]
  |  Branch (17196:24): [True: 0, False: 0]
  ------------------
17197|      0|      r.headers.emplace("Content-Type", ct);
17198|      0|    }
17199|      0|    if (!r.has_header("Content-Length")) {
  ------------------
  |  Branch (17199:9): [True: 0, False: 0]
  ------------------
17200|      0|      r.headers.emplace("Content-Length", std::to_string(r.body.size()));
17201|      0|    }
17202|      0|  }
17203|  3.31k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE5beginEv:
 1306|  6.63k|  iterator begin() { return make_iter(0, npos()); }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE3endEv:
 1307|  15.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:
 1274|  30.3k|    template <typename U> bool operator!=(const iterator_t<U> &rhs) const {
 1275|  30.3k|      return idx_ != rhs.idx_;
 1276|  30.3k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEdeEv:
 1231|  15.4k|    reference operator*() const { return data_[idx_]; }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEppEv:
 1234|  18.5k|    iterator_t &operator++() {
 1235|       |      // Saturating, so that advancing past the last entry of a key stays at
 1236|       |      // end() instead of running off the container.
 1237|  18.5k|      if (idx_ >= size_) { return *this; }
  ------------------
  |  Branch (1237:11): [True: 0, False: 18.5k]
  ------------------
 1238|  18.5k|      ++idx_;
 1239|  18.5k|      if (key_idx_ != npos()) {
  ------------------
  |  Branch (1239:11): [True: 3.07k, False: 15.4k]
  ------------------
 1240|  3.85k|        while (idx_ < size_ && !matches(idx_)) {
  ------------------
  |  Branch (1240:16): [True: 2.95k, False: 896]
  |  Branch (1240:32): [True: 782, False: 2.17k]
  ------------------
 1241|    782|          ++idx_;
 1242|    782|        }
 1243|  3.07k|      }
 1244|  18.5k|      return *this;
 1245|  18.5k|    }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEE7matchesEm:
 1285|  2.95k|    bool matches(size_type i) const {
 1286|  2.95k|      return keys_equal(data_[i].first, data_[key_idx_].first);
 1287|  2.95k|    }
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE13emplace_frontIJRA5_KcS8_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1335|  3.31k|  template <typename... Args> iterator emplace_front(Args &&...args) {
 1336|  3.31k|    entries_.emplace(entries_.begin(), std::forward<Args>(args)...);
 1337|  3.31k|    return make_iter(0, npos());
 1338|  3.31k|  }
_ZN7httplib6detail30make_default_host_header_valueERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEibi:
13886|  3.31k|                                                  int address_family) {
13887|  3.31k|  if (address_family == AF_UNIX) { return "localhost"; }
  ------------------
  |  Branch (13887:7): [True: 0, False: 3.31k]
  ------------------
13888|  3.31k|  return make_host_and_port_string(host, port, is_ssl);
13889|  3.31k|}
_ZN7httplib6detail25make_host_and_port_stringERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEib:
13844|  3.31k|                                             bool is_ssl) {
13845|  3.31k|  auto result = prepare_host_string(host);
13846|       |
13847|       |  // Append port if not default
13848|  3.31k|  if ((!is_ssl && port == 80) || (is_ssl && port == 443)) {
  ------------------
  |  Branch (13848:8): [True: 3.31k, False: 0]
  |  Branch (13848:19): [True: 0, False: 3.31k]
  |  Branch (13848:35): [True: 0, False: 3.31k]
  |  Branch (13848:45): [True: 0, False: 0]
  ------------------
13849|      0|    ; // do nothing
13850|  3.31k|  } else {
13851|  3.31k|    result += ":" + std::to_string(port);
13852|  3.31k|  }
13853|       |
13854|  3.31k|  return result;
13855|  3.31k|}
_ZN7httplib6detail19prepare_host_stringERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
13831|  3.31k|inline std::string prepare_host_string(const std::string &host) {
13832|       |  // Enclose IPv6 address in brackets (but not if already enclosed)
13833|  3.31k|  if (host.find(':') == std::string::npos ||
  ------------------
  |  Branch (13833:7): [True: 3.31k, False: 0]
  ------------------
13834|  3.31k|      (!host.empty() && host[0] == '[')) {
  ------------------
  |  Branch (13834:8): [True: 0, False: 0]
  |  Branch (13834:25): [True: 0, False: 0]
  ------------------
13835|       |    // IPv4, hostname, or already bracketed IPv6
13836|  3.31k|    return host;
13837|  3.31k|  } else {
13838|       |    // IPv6 address without brackets
13839|      0|    return "[" + host + "]";
13840|      0|  }
13841|  3.31k|}
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE7emplaceIJRA7_KcRA4_SD_EEENSB_10iterator_tINS2_4pairIS8_S8_EEEEDpOT_:
 1328|  3.31k|  template <typename... Args> iterator emplace(Args &&...args) {
 1329|  3.31k|    entries_.emplace_back(std::forward<Args>(args)...);
 1330|  3.31k|    return make_iter(entries_.size() - 1, npos());
 1331|  3.31k|  }
_ZN7httplib6detail29add_default_user_agent_headerERNS_7RequestE:
13891|  3.31k|inline void add_default_user_agent_header(Request &req) {
13892|  3.31k|#ifndef CPPHTTPLIB_NO_DEFAULT_USER_AGENT
13893|  3.31k|  if (!req.has_header("User-Agent")) {
  ------------------
  |  Branch (13893:7): [True: 3.31k, False: 0]
  ------------------
13894|  3.31k|    req.set_header("User-Agent",
13895|  3.31k|                   std::string("cpp-httplib/") + CPPHTTPLIB_VERSION);
  ------------------
  |  |   11|  3.31k|#define CPPHTTPLIB_VERSION "0.69.0"
  ------------------
13896|  3.31k|  }
13897|       |#else
13898|       |  (void)req;
13899|       |#endif
13900|  3.31k|}
_ZN7httplib10ClientImpl22add_credential_headersERNS_7RequestE:
17943|  3.31k|inline void ClientImpl::add_credential_headers(Request &req) {
17944|       |  // A CONNECT request is read by the proxy; everything sent through the tunnel
17945|       |  // it opens is read by the origin. Each credential goes only to its own hop.
17946|  3.31k|  auto is_connect = req.method == "CONNECT";
17947|       |
17948|  3.31k|  if (!is_connect) {
  ------------------
  |  Branch (17948:7): [True: 3.31k, False: 0]
  ------------------
17949|  3.31k|    detail::add_authorization_header(req, basic_auth_username_,
17950|  3.31k|                                     basic_auth_password_,
17951|  3.31k|                                     bearer_token_auth_token_, false);
17952|  3.31k|  }
17953|       |
17954|       |  // Proxy-Authorization is only sent when the proxy reads this message —
17955|       |  // otherwise NO_PROXY-matched requests, and requests inside a TLS tunnel,
17956|       |  // would leak proxy credentials to the destination server.
17957|  3.31k|  if (is_proxy_enabled_for_host(host_) && (!is_ssl() || is_connect)) {
  ------------------
  |  Branch (17957:7): [True: 0, False: 3.31k]
  |  Branch (17957:44): [True: 0, False: 0]
  |  Branch (17957:57): [True: 0, False: 0]
  ------------------
17958|      0|    detail::add_authorization_header(req, proxy_basic_auth_username_,
17959|      0|                                     proxy_basic_auth_password_,
17960|      0|                                     proxy_bearer_token_auth_token_, true);
17961|      0|  }
17962|  3.31k|}
_ZN7httplib6detail24add_authorization_headerERNS_7RequestERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_SB_b:
12854|  3.31k|                                     const std::string &token, bool is_proxy) {
12855|  3.31k|  if (req.has_header(is_proxy ? "Proxy-Authorization" : "Authorization")) {
  ------------------
  |  Branch (12855:7): [True: 0, False: 3.31k]
  |  Branch (12855:22): [True: 0, False: 3.31k]
  ------------------
12856|      0|    return;
12857|      0|  }
12858|  3.31k|  if (!username.empty() || !password.empty()) {
  ------------------
  |  Branch (12858:7): [True: 0, False: 3.31k]
  |  Branch (12858:28): [True: 0, False: 3.31k]
  ------------------
12859|      0|    req.headers.insert(
12860|      0|        make_basic_authentication_header(username, password, is_proxy));
12861|  3.31k|  } else if (!token.empty()) {
  ------------------
  |  Branch (12861:14): [True: 0, False: 3.31k]
  ------------------
12862|      0|    req.headers.insert(
12863|      0|        make_bearer_token_authentication_header(token, is_proxy));
12864|      0|  }
12865|  3.31k|}
_ZNK7httplib10ClientImpl25is_proxy_enabled_for_hostERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
16862|  3.31k|ClientImpl::is_proxy_enabled_for_host(const std::string &host) const {
16863|  3.31k|  if (proxy_host_.empty() || proxy_port_ == -1) { return false; }
  ------------------
  |  Branch (16863:7): [True: 3.31k, False: 0]
  |  Branch (16863:30): [True: 0, False: 0]
  ------------------
16864|      0|  if (no_proxy_entries_.empty()) { return true; }
  ------------------
  |  Branch (16864:7): [True: 0, False: 0]
  ------------------
16865|       |  // host_ is const so its normalized form is invariant; cache it. The
16866|       |  // cross-host path (setup_redirect_client passing next_host) re-normalizes.
16867|      0|  if (host == host_) {
  ------------------
  |  Branch (16867:7): [True: 0, False: 0]
  ------------------
16868|      0|    if (!host_normalized_valid_) {
  ------------------
  |  Branch (16868:9): [True: 0, False: 0]
  ------------------
16869|      0|      host_normalized_ = detail::normalize_target(host_);
16870|      0|      host_normalized_valid_ = true;
16871|      0|    }
16872|      0|    return !detail::host_matches_no_proxy(host_normalized_, no_proxy_entries_);
16873|      0|  }
16874|      0|  auto target = detail::normalize_target(host);
16875|      0|  return !detail::host_matches_no_proxy(target, no_proxy_entries_);
16876|      0|}
_ZN7httplib6detail12BufferStreamC2Ev:
 4110|  3.31k|  BufferStream() = default;
_ZNK7httplib10ClientImpl19make_request_targetERKNS_7RequestE:
17935|  3.31k|inline std::string ClientImpl::make_request_target(const Request &req) const {
17936|  3.31k|  auto target = detail::encode_request_target(req.path, path_encode_);
17937|  3.31k|  if (detail::query_of(req.path).empty() && !req.params.empty()) {
  ------------------
  |  Branch (17937:7): [True: 3.31k, False: 0]
  |  Branch (17937:7): [True: 0, False: 3.31k]
  |  Branch (17937:45): [True: 0, False: 3.31k]
  ------------------
17938|      0|    target = append_query_params(target, req.params);
17939|      0|  }
17940|  3.31k|  return target;
17941|  3.31k|}
_ZN7httplib6detail21encode_request_targetERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEb:
10167|  3.31k|                                         bool path_encode) {
10168|       |  // The fragment stays with the client (RFC 9110 §7.1).
10169|  3.31k|  auto target = uri.substr(0, uri.find('#'));
10170|       |
10171|       |  // `substr(0, npos)` yields the whole string, which is what the no-query
10172|       |  // case needs.
10173|  3.31k|  auto query_pos = target.find('?');
10174|  3.31k|  auto path_part = target.substr(0, query_pos);
10175|  3.31k|  std::string query_part;
10176|  3.31k|  if (query_pos != std::string::npos) {
  ------------------
  |  Branch (10176:7): [True: 0, False: 3.31k]
  ------------------
10177|      0|    query_part = target.substr(query_pos + 1);
10178|      0|  }
10179|       |
10180|  3.31k|  auto result = path_encode ? encode_path(path_part) : std::move(path_part);
  ------------------
  |  Branch (10180:17): [True: 3.31k, False: 0]
  ------------------
10181|       |
10182|  3.31k|  if (!query_part.empty()) {
  ------------------
  |  Branch (10182:7): [True: 0, False: 3.31k]
  ------------------
10183|       |    // When path encoding is disabled the caller has supplied an already-encoded
10184|       |    // target and expects the exact bytes to be sent on the wire, so skip
10185|       |    // normalization for the query too. Normalizing would decode-then-re-encode
10186|       |    // it and corrupt pre-encoded binary payloads (e.g. turning `%20` into `+`,
10187|       |    // which a strict RFC 3986 server decodes back as `+`, not a space).
10188|      0|    if (path_encode) {
  ------------------
  |  Branch (10188:9): [True: 0, False: 0]
  ------------------
10189|      0|      auto normalized = normalize_query_string(query_part);
10190|      0|      if (!normalized.empty()) {
  ------------------
  |  Branch (10190:11): [True: 0, False: 0]
  ------------------
10191|      0|        result += '?';
10192|      0|        result += normalized;
10193|      0|      }
10194|      0|    } else {
10195|      0|      result += '?';
10196|      0|      result += query_part;
10197|      0|    }
10198|      0|  }
10199|       |
10200|  3.31k|  return result;
10201|  3.31k|}
_ZN7httplib6detail11encode_pathERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6482|  3.31k|inline std::string encode_path(const std::string &s) {
 6483|  3.31k|  std::string result;
 6484|  3.31k|  result.reserve(s.size());
 6485|       |
 6486|  6.63k|  for (size_t i = 0; s[i]; i++) {
  ------------------
  |  Branch (6486:22): [True: 3.31k, False: 3.31k]
  ------------------
 6487|  3.31k|    switch (s[i]) {
 6488|      0|    case ' ': result += "%20"; break;
  ------------------
  |  Branch (6488:5): [True: 0, False: 3.31k]
  ------------------
 6489|      0|    case '+': result += "%2B"; break;
  ------------------
  |  Branch (6489:5): [True: 0, False: 3.31k]
  ------------------
 6490|      0|    case '\'': result += "%27"; break;
  ------------------
  |  Branch (6490:5): [True: 0, False: 3.31k]
  ------------------
 6491|      0|    case ',': result += "%2C"; break;
  ------------------
  |  Branch (6491:5): [True: 0, False: 3.31k]
  ------------------
 6492|       |    // case ':': result += "%3A"; break; // ok? probably...
 6493|      0|    case ';': result += "%3B"; break;
  ------------------
  |  Branch (6493:5): [True: 0, False: 3.31k]
  ------------------
 6494|  3.31k|    default:
  ------------------
  |  Branch (6494:5): [True: 3.31k, False: 0]
  ------------------
 6495|  3.31k|      auto c = static_cast<uint8_t>(s[i]);
 6496|       |      // Control characters (incl. CR/LF) and non-ASCII bytes are not allowed
 6497|       |      // in a request-target as-is.
 6498|  3.31k|      if (c < 0x20 || c == 0x7f || c >= 0x80) {
  ------------------
  |  Branch (6498:11): [True: 0, False: 3.31k]
  |  Branch (6498:23): [True: 0, False: 3.31k]
  |  Branch (6498:36): [True: 0, False: 3.31k]
  ------------------
 6499|      0|        result += '%';
 6500|      0|        char hex[4];
 6501|      0|        auto len = snprintf(hex, sizeof(hex) - 1, "%02X", c);
 6502|      0|        assert(len == 2);
  ------------------
  |  Branch (6502:9): [True: 0, False: 0]
  ------------------
 6503|      0|        result.append(hex, static_cast<size_t>(len));
 6504|  3.31k|      } else {
 6505|  3.31k|        result += s[i];
 6506|  3.31k|      }
 6507|  3.31k|      break;
 6508|  3.31k|    }
 6509|  3.31k|  }
 6510|       |
 6511|  3.31k|  return result;
 6512|  3.31k|}
_ZN7httplib6detail5splitEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 6732|  1.46k|                  std::function<void(const char *, const char *)> fn) {
 6733|  1.46k|  return split(b, e, d, (std::numeric_limits<size_t>::max)(), std::move(fn));
 6734|  1.46k|}
_ZN7httplib6detail5splitEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 6737|  1.46k|                  std::function<void(const char *, const char *)> fn) {
 6738|  1.46k|  size_t i = 0;
 6739|  1.46k|  size_t beg = 0;
 6740|  1.46k|  size_t count = 1;
 6741|       |
 6742|  84.2k|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (6742:10): [True: 84.2k, False: 0]
  |  Branch (6742:10): [True: 82.7k, False: 1.46k]
  ------------------
 6743|  82.7k|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (6743:9): [True: 24.1k, False: 58.6k]
  |  Branch (6743:22): [True: 24.1k, False: 0]
  ------------------
 6744|  24.1k|      auto r = trim(b, e, beg, i);
 6745|  24.1k|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6745:11): [True: 6.61k, False: 17.5k]
  ------------------
 6746|  24.1k|      beg = i + 1;
 6747|  24.1k|      count++;
 6748|  24.1k|    }
 6749|  82.7k|    i++;
 6750|  82.7k|  }
 6751|       |
 6752|  1.46k|  if (i) {
  ------------------
  |  Branch (6752:7): [True: 1.25k, False: 216]
  ------------------
 6753|  1.25k|    auto r = trim(b, e, beg, i);
 6754|  1.25k|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (6754:9): [True: 1.11k, False: 138]
  ------------------
 6755|  1.25k|  }
 6756|  1.46k|}
_ZN7httplib6detail6is_hexEcRi:
 5782|  14.2k|inline bool is_hex(char c, int &v) {
 5783|  14.2k|  if (is_ascii_digit(c)) {
  ------------------
  |  Branch (5783:7): [True: 9.87k, False: 4.37k]
  ------------------
 5784|  9.87k|    v = c - '0';
 5785|  9.87k|    return true;
 5786|  9.87k|  } else if ('A' <= c && c <= 'F') {
  ------------------
  |  Branch (5786:14): [True: 3.83k, False: 542]
  |  Branch (5786:26): [True: 2.29k, False: 1.54k]
  ------------------
 5787|  2.29k|    v = c - 'A' + 10;
 5788|  2.29k|    return true;
 5789|  2.29k|  } else if ('a' <= c && c <= 'f') {
  ------------------
  |  Branch (5789:14): [True: 1.53k, False: 550]
  |  Branch (5789:26): [True: 1.52k, False: 6]
  ------------------
 5790|  1.52k|    v = c - 'a' + 10;
 5791|  1.52k|    return true;
 5792|  1.52k|  }
 5793|    556|  return false;
 5794|  14.2k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_8equal_toIS8_EEE5emptyEv:
 1313|  3.31k|  bool empty() const { return entries_.empty(); }
_ZN7httplib6detail8query_ofERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
10155|  6.63k|inline std::string query_of(const std::string &path) {
10156|  6.63k|  auto fragment_pos = path.find('#');
10157|  6.63k|  auto query_pos = path.find('?');
10158|  6.63k|  return query_pos < fragment_pos
  ------------------
  |  Branch (10158:10): [True: 0, False: 6.63k]
  ------------------
10159|  6.63k|             ? path.substr(query_pos + 1, fragment_pos - query_pos - 1)
10160|  6.63k|             : std::string();
10161|  6.63k|}
_ZN7httplib6detail18write_request_lineERNS_6StreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_:
 9678|  3.31k|                                  const std::string &path) {
 9679|       |  // Neither the method nor the request target may carry CR/LF, SP or other
 9680|       |  // control octets; otherwise a value smuggled into either splits the request
 9681|       |  // line and injects headers or a whole request.
 9682|  3.31k|  if (!fields::is_token(method)) { return -1; }
  ------------------
  |  Branch (9682:7): [True: 0, False: 3.31k]
  ------------------
 9683|  3.31k|  if (!fields::is_request_target(path)) { return -1; }
  ------------------
  |  Branch (9683:7): [True: 0, False: 3.31k]
  ------------------
 9684|       |
 9685|  3.31k|  std::string s = method;
 9686|  3.31k|  s += ' ';
 9687|  3.31k|  s += path;
 9688|  3.31k|  s += " HTTP/1.1\r\n";
 9689|  3.31k|  return strm.write(s.data(), s.size());
 9690|  3.31k|}
_ZN7httplib6detail6fields17is_request_targetERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE:
11311|  3.31k|inline bool is_request_target(const std::string &s) {
11312|  3.31k|  return std::all_of(s.begin(), s.end(), is_field_vchar);
11313|  3.31k|}
_ZN7httplib6detail23check_and_write_headersINSt3__18functionIFlRNS_6StreamERNS0_26insertion_ordered_multimapINS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEEEEEEEbS5_SG_T_RNS_5ErrorE:
14081|  3.31k|                                    T header_writer, Error &error) {
14082|  15.4k|  for (const auto &h : headers) {
  ------------------
  |  Branch (14082:22): [True: 15.4k, False: 3.31k]
  ------------------
14083|  15.4k|    if (!detail::fields::is_field_valid(h.first, h.second)) {
  ------------------
  |  Branch (14083:9): [True: 0, False: 15.4k]
  ------------------
14084|      0|      error = Error::InvalidHeaders;
14085|      0|      return false;
14086|      0|    }
14087|  15.4k|  }
14088|  3.31k|  if (header_writer(strm, headers) <= 0) {
  ------------------
  |  Branch (14088:7): [True: 0, False: 3.31k]
  ------------------
14089|      0|    error = Error::Write;
14090|      0|    return false;
14091|      0|  }
14092|  3.31k|  return true;
14093|  3.31k|}
_ZNK7httplib6detail12BufferStream10get_bufferEv:
13722|  3.31k|inline const std::string &BufferStream::get_buffer() const { return buffer; }
_ZN7httplib6detail10write_dataERNS_6StreamEPKcm:
 9720|  3.31k|inline bool write_data(Stream &strm, const char *d, size_t l) {
 9721|  3.31k|  size_t offset = 0;
 9722|  6.63k|  while (offset < l) {
  ------------------
  |  Branch (9722:10): [True: 3.31k, False: 3.31k]
  ------------------
 9723|  3.31k|    auto length = strm.write(d + offset, l - offset);
 9724|  3.31k|    if (length < 0) { return false; }
  ------------------
  |  Branch (9724:9): [True: 0, False: 3.31k]
  ------------------
 9725|  3.31k|    offset += static_cast<size_t>(length);
 9726|  3.31k|  }
 9727|  3.31k|  return true;
 9728|  3.31k|}
_ZNK7httplib10ClientImpl18read_response_lineERNS_6StreamERKNS_7RequestERNS_8ResponseEb:
17004|  3.31k|                                           bool skip_100_continue) const {
17005|  3.31k|  std::array<char, 2048> buf{};
17006|       |
17007|  3.31k|  detail::stream_line_reader line_reader(strm, buf.data(), buf.size());
17008|       |
17009|  3.31k|  if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (17009:7): [True: 9, False: 3.31k]
  ------------------
17010|       |
17011|  3.31k|  if (!detail::parse_status_line(line_reader.ptr(), res.version, res.status,
  ------------------
  |  Branch (17011:7): [True: 234, False: 3.07k]
  ------------------
17012|  3.31k|                                 res.reason)) {
17013|    234|    return req.method == "CONNECT";
17014|    234|  }
17015|       |
17016|       |  // Skip interim (1xx) responses along with their header fields, except a 100
17017|       |  // Continue the caller handles itself for Expect: 100-continue. 101 ends
17018|       |  // HTTP on the connection, so it is final. A server sending them without end
17019|       |  // would hold the client, so there may be only so many.
17020|  3.07k|  size_t interim_count = 0;
17021|  6.01k|  while (100 <= res.status && res.status < 200 &&
  ------------------
  |  Branch (17021:10): [True: 5.58k, False: 424]
  |  Branch (17021:31): [True: 3.34k, False: 2.23k]
  ------------------
17022|  3.34k|         res.status != StatusCode::SwitchingProtocol_101 &&
  ------------------
  |  Branch (17022:10): [True: 3.30k, False: 45]
  ------------------
17023|  3.30k|         (skip_100_continue || res.status != StatusCode::Continue_100)) {
  ------------------
  |  Branch (17023:11): [True: 3.30k, False: 0]
  |  Branch (17023:32): [True: 0, False: 0]
  ------------------
17024|  3.30k|    if (++interim_count > CPPHTTPLIB_INTERIM_RESPONSE_MAX_COUNT) {
  ------------------
  |  |  139|  3.30k|#define CPPHTTPLIB_INTERIM_RESPONSE_MAX_COUNT 100
  ------------------
  |  Branch (17024:9): [True: 1, False: 3.30k]
  ------------------
17025|      1|      return false;
17026|      1|    }
17027|  3.30k|    Headers interim_headers;
17028|  3.30k|    if (!detail::read_headers(strm, interim_headers)) { return false; }
  ------------------
  |  Branch (17028:9): [True: 281, False: 3.02k]
  ------------------
17029|  3.02k|    if (!line_reader.getline()) { return false; } // next response line
  ------------------
  |  Branch (17029:9): [True: 32, False: 2.98k]
  ------------------
17030|       |
17031|  2.98k|    if (!detail::parse_status_line(line_reader.ptr(), res.version, res.status,
  ------------------
  |  Branch (17031:9): [True: 55, False: 2.93k]
  ------------------
17032|  2.98k|                                   res.reason)) {
17033|     55|      return false;
17034|     55|    }
17035|  2.98k|  }
17036|       |
17037|  2.70k|  return true;
17038|  3.07k|}
_ZN7httplib6detail18stream_line_readerC2ERNS_6StreamEPcm:
 6849|  18.3k|    : strm_(strm), fixed_buffer_(fixed_buffer),
 6850|  18.3k|      fixed_buffer_size_(fixed_buffer_size) {}
_ZN7httplib6detail18stream_line_reader7getlineEv:
 6873|  44.2k|inline bool stream_line_reader::getline() {
 6874|  44.2k|  fixed_buffer_used_size_ = 0;
 6875|  44.2k|  growable_buffer_.clear();
 6876|       |
 6877|  44.2k|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6878|  44.2k|  char prev_byte = 0;
 6879|  44.2k|#endif
 6880|       |
 6881|  4.24M|  for (size_t i = 0;; i++) {
 6882|       |    // Fast path: whatever the stream has already buffered can be scanned for
 6883|       |    // the terminator in one pass. Asking for a byte at a time costs a virtual
 6884|       |    // call, a bounds check and a one-byte copy per character of the request.
 6885|  4.24M|    size_t buffered_size = 0;
 6886|  4.24M|    if (auto buffered = strm_.buffered_data(buffered_size)) {
  ------------------
  |  Branch (6886:14): [True: 0, False: 4.24M]
  ------------------
 6887|      0|      auto take = buffered_size;
 6888|      0|      auto terminated = false;
 6889|       |
 6890|      0|      for (size_t at = 0; at < buffered_size;) {
  ------------------
  |  Branch (6890:27): [True: 0, False: 0]
  ------------------
 6891|      0|        auto nl = static_cast<const char *>(
 6892|      0|            memchr(buffered + at, '\n', buffered_size - at));
 6893|      0|        if (!nl) { break; }
  ------------------
  |  Branch (6893:13): [True: 0, False: 0]
  ------------------
 6894|      0|        auto pos = static_cast<size_t>(nl - buffered);
 6895|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6896|       |        take = pos + 1;
 6897|       |        terminated = true;
 6898|       |        break;
 6899|       |#else
 6900|       |        // A bare LF does not end the line; keep looking for CRLF. The CR may
 6901|       |        // be the last byte of an earlier chunk, hence prev_byte.
 6902|      0|        if ((pos > 0 ? buffered[pos - 1] : prev_byte) == '\r') {
  ------------------
  |  Branch (6902:13): [True: 0, False: 0]
  |  Branch (6902:14): [True: 0, False: 0]
  ------------------
 6903|      0|          take = pos + 1;
 6904|      0|          terminated = true;
 6905|      0|          break;
 6906|      0|        }
 6907|      0|        at = pos + 1;
 6908|      0|#endif
 6909|      0|      }
 6910|       |
 6911|      0|      if (size() + take > CPPHTTPLIB_MAX_LINE_LENGTH) { return false; }
  ------------------
  |  |  238|      0|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6911:11): [True: 0, False: 0]
  ------------------
 6912|      0|#ifndef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6913|      0|      prev_byte = buffered[take - 1];
 6914|      0|#endif
 6915|      0|      append(buffered, take);
 6916|      0|      strm_.consume_buffered(take);
 6917|      0|      i += take;
 6918|      0|      if (terminated) { return true; }
  ------------------
  |  Branch (6918:11): [True: 0, False: 0]
  ------------------
 6919|      0|      continue;
 6920|      0|    }
 6921|       |
 6922|  4.24M|    if (size() >= CPPHTTPLIB_MAX_LINE_LENGTH) {
  ------------------
  |  |  238|  4.24M|#define CPPHTTPLIB_MAX_LINE_LENGTH 32768
  ------------------
  |  Branch (6922:9): [True: 3, False: 4.24M]
  ------------------
 6923|       |      // Treat exceptionally long lines as an error to
 6924|       |      // prevent infinite loops/memory exhaustion
 6925|      3|      return false;
 6926|      3|    }
 6927|  4.24M|    char byte;
 6928|  4.24M|    auto n = strm_.read(&byte, 1);
 6929|       |
 6930|  4.24M|    if (n < 0) {
  ------------------
  |  Branch (6930:9): [True: 0, False: 4.24M]
  ------------------
 6931|      0|      return false;
 6932|  4.24M|    } else if (n == 0) {
  ------------------
  |  Branch (6932:16): [True: 1.45k, False: 4.24M]
  ------------------
 6933|  1.45k|      if (i == 0) {
  ------------------
  |  Branch (6933:11): [True: 562, False: 892]
  ------------------
 6934|    562|        return false;
 6935|    892|      } else {
 6936|    892|        break;
 6937|    892|      }
 6938|  1.45k|    }
 6939|       |
 6940|  4.24M|    append(byte);
 6941|       |
 6942|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 6943|       |    if (byte == '\n') { break; }
 6944|       |#else
 6945|  4.24M|    if (prev_byte == '\r' && byte == '\n') { break; }
  ------------------
  |  Branch (6945:9): [True: 43.5k, False: 4.19M]
  |  Branch (6945:30): [True: 42.8k, False: 737]
  ------------------
 6946|  4.19M|    prev_byte = byte;
 6947|  4.19M|#endif
 6948|  4.19M|  }
 6949|       |
 6950|  43.7k|  return true;
 6951|  44.2k|}
_ZNK7httplib6detail18stream_line_reader4sizeEv:
 6860|  4.39M|inline size_t stream_line_reader::size() const {
 6861|  4.39M|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6861:7): [True: 2.01M, False: 2.37M]
  ------------------
 6862|  2.01M|    return fixed_buffer_used_size_;
 6863|  2.37M|  } else {
 6864|  2.37M|    return growable_buffer_.size();
 6865|  2.37M|  }
 6866|  4.39M|}
_ZN7httplib6detail18stream_line_reader6appendEPKcm:
 6955|  4.24M|inline void stream_line_reader::append(const char *data, size_t size) {
 6956|       |  // Once the line has outgrown the fixed buffer everything must keep going to
 6957|       |  // the growable one, even if a later chunk would have fit. Without the
 6958|       |  // emptiness check a short append after a long one would land in the fixed
 6959|       |  // buffer, which ptr() and size() no longer look at, and be lost.
 6960|  4.24M|  if (growable_buffer_.empty() &&
  ------------------
  |  Branch (6960:7): [True: 1.86M, False: 2.37M]
  ------------------
 6961|  1.86M|      fixed_buffer_used_size_ + size < fixed_buffer_size_) {
  ------------------
  |  Branch (6961:7): [True: 1.86M, False: 971]
  ------------------
 6962|  1.86M|    memcpy(fixed_buffer_ + fixed_buffer_used_size_, data, size);
 6963|  1.86M|    fixed_buffer_used_size_ += size;
 6964|  1.86M|    fixed_buffer_[fixed_buffer_used_size_] = '\0';
 6965|  2.37M|  } else {
 6966|       |    // Unlike the per-character overload, this can be the very first append of
 6967|       |    // the line, so the fixed buffer may hold nothing and carry no terminator
 6968|       |    // yet. assign() takes an explicit length and does not need one.
 6969|  2.37M|    if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6969:9): [True: 971, False: 2.37M]
  ------------------
 6970|    971|      growable_buffer_.assign(fixed_buffer_, fixed_buffer_used_size_);
 6971|    971|    }
 6972|  2.37M|    growable_buffer_.append(data, size);
 6973|  2.37M|  }
 6974|  4.24M|}
_ZN7httplib6detail18stream_line_reader6appendEc:
 6953|  4.24M|inline void stream_line_reader::append(char c) { append(&c, 1); }
_ZN7httplib6detail17parse_status_lineEPKcRNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERiSA_:
 9286|  6.29k|                              int &status, std::string &reason) {
 9287|  6.29k|  if (std::strncmp(line, "HTTP/1.", 7) != 0 ||
  ------------------
  |  Branch (9287:7): [True: 153, False: 6.14k]
  ------------------
 9288|  6.14k|      (line[7] != '0' && line[7] != '1') || line[8] != ' ' ||
  ------------------
  |  Branch (9288:8): [True: 4.12k, False: 2.02k]
  |  Branch (9288:26): [True: 24, False: 4.10k]
  |  Branch (9288:45): [True: 28, False: 6.09k]
  ------------------
 9289|  6.09k|      !is_ascii_digit(line[9]) || !is_ascii_digit(line[10]) ||
  ------------------
  |  Branch (9289:7): [True: 15, False: 6.07k]
  |  Branch (9289:35): [True: 5, False: 6.07k]
  ------------------
 9290|  6.07k|      !is_ascii_digit(line[11])) {
  ------------------
  |  Branch (9290:7): [True: 1, False: 6.07k]
  ------------------
 9291|    226|    return false;
 9292|    226|  }
 9293|       |
 9294|  6.07k|  auto p = line + 12;
 9295|  6.07k|  auto reason_begin = p;
 9296|  6.07k|  if (*p == ' ') {
  ------------------
  |  Branch (9296:7): [True: 681, False: 5.39k]
  ------------------
 9297|    681|    reason_begin = ++p;
 9298|    681|    p += std::strcspn(p, "\r\n");
 9299|    681|  }
 9300|  6.07k|  auto reason_end = p;
 9301|       |
 9302|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 9303|       |  if (*p == '\r') { p++; }
 9304|       |#else
 9305|  6.07k|  if (*p++ != '\r') { return false; }
  ------------------
  |  Branch (9305:7): [True: 44, False: 6.02k]
  ------------------
 9306|  6.02k|#endif
 9307|  6.02k|  if (*p++ != '\n' || *p != '\0') { return false; }
  ------------------
  |  Branch (9307:7): [True: 19, False: 6.01k]
  |  Branch (9307:23): [True: 0, False: 6.01k]
  ------------------
 9308|       |
 9309|  6.01k|  version.assign(line, 8);
 9310|  6.01k|  status = (line[9] - '0') * 100 + (line[10] - '0') * 10 + (line[11] - '0');
 9311|  6.01k|  reason.assign(reason_begin, reason_end);
 9312|  6.01k|  return true;
 9313|  6.02k|}
_ZNK7httplib6detail18stream_line_reader3ptrEv:
 6852|   100k|inline const char *stream_line_reader::ptr() const {
 6853|   100k|  if (growable_buffer_.empty()) {
  ------------------
  |  Branch (6853:7): [True: 97.4k, False: 2.83k]
  ------------------
 6854|  97.4k|    return fixed_buffer_;
 6855|  97.4k|  } else {
 6856|  2.83k|    return growable_buffer_.data();
 6857|  2.83k|  }
 6858|   100k|}
_ZN7httplib10ClientImpl18write_request_bodyERNS_6StreamERNS_7RequestERNS_5ErrorE:
18089|  3.31k|                                           Error &error) {
18090|  3.31k|  if (req.body.empty()) {
  ------------------
  |  Branch (18090:7): [True: 3.31k, False: 0]
  ------------------
18091|  3.31k|    return write_content_with_provider(strm, req, error);
18092|  3.31k|  }
18093|       |
18094|      0|  if (req.upload_progress) {
  ------------------
  |  Branch (18094:7): [True: 0, False: 0]
  ------------------
18095|      0|    auto body_size = req.body.size();
18096|      0|    size_t written = 0;
18097|      0|    auto data = req.body.data();
18098|       |
18099|      0|    while (written < body_size) {
  ------------------
  |  Branch (18099:12): [True: 0, False: 0]
  ------------------
18100|      0|      size_t to_write = (std::min)(CPPHTTPLIB_SEND_BUFSIZ, body_size - written);
  ------------------
  |  |  203|      0|#define CPPHTTPLIB_SEND_BUFSIZ size_t(16384u)
  ------------------
18101|      0|      if (!detail::write_data(strm, data + written, to_write)) {
  ------------------
  |  Branch (18101:11): [True: 0, False: 0]
  ------------------
18102|      0|        error = Error::Write;
18103|      0|        return false;
18104|      0|      }
18105|      0|      written += to_write;
18106|       |
18107|      0|      if (!req.upload_progress(written, body_size)) {
  ------------------
  |  Branch (18107:11): [True: 0, False: 0]
  ------------------
18108|      0|        error = Error::Canceled;
18109|      0|        return false;
18110|      0|      }
18111|      0|    }
18112|      0|  } else {
18113|      0|    if (!detail::write_data(strm, req.body.data(), req.body.size())) {
  ------------------
  |  Branch (18113:9): [True: 0, False: 0]
  ------------------
18114|      0|      error = Error::Write;
18115|      0|      return false;
18116|      0|    }
18117|      0|  }
18118|       |
18119|      0|  return true;
18120|      0|}
_ZNK7httplib10ClientImpl27write_content_with_providerERNS_6StreamERKNS_7RequestERNS_5ErrorE:
17914|  3.31k|                                                    Error &error) const {
17915|  3.31k|  auto is_shutting_down = []() { return false; };
17916|       |
17917|  3.31k|  if (req.is_chunked_content_provider_) {
  ------------------
  |  Branch (17917:7): [True: 0, False: 3.31k]
  ------------------
17918|      0|    auto compressor = compress_ ? detail::create_compressor().first
  ------------------
  |  Branch (17918:23): [True: 0, False: 0]
  ------------------
17919|      0|                                : std::unique_ptr<detail::compressor>();
17920|      0|    if (!compressor) {
  ------------------
  |  Branch (17920:9): [True: 0, False: 0]
  ------------------
17921|      0|      compressor = detail::make_unique<detail::nocompressor>();
17922|      0|    }
17923|       |
17924|      0|    return detail::write_content_chunked(strm, req.content_provider_,
17925|      0|                                         is_shutting_down, *compressor, error);
17926|  3.31k|  } else {
17927|  3.31k|    return detail::write_content_with_progress(
17928|  3.31k|        strm, req.content_provider_, 0, req.content_length_, is_shutting_down,
17929|  3.31k|        req.upload_progress, error);
17930|  3.31k|  }
17931|  3.31k|}
_ZN7httplib8DataSinkC2Ev:
 1601|  3.31k|  DataSink() : os(&sb_), sb_(*this) {}
_ZN7httplib8DataSink19data_sink_streambufC2ERS0_:
 1624|  3.31k|    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_:
 9736|  3.31k|                                        Error &error) {
 9737|  3.31k|  size_t end_offset = offset + length;
 9738|  3.31k|  size_t start_offset = offset;
 9739|  3.31k|  auto ok = true;
 9740|  3.31k|  auto finished = false;
 9741|  3.31k|  DataSink data_sink;
 9742|       |
 9743|  3.31k|  data_sink.write = [&](const char *d, size_t l) -> bool {
 9744|  3.31k|    if (ok) {
 9745|       |      // Bytes past `length` would follow the framed body, where the peer reads
 9746|       |      // them as the next message. Write only what fits and fail the rest.
 9747|  3.31k|      if (l > end_offset - offset) {
 9748|  3.31k|        l = end_offset - offset;
 9749|  3.31k|        ok = false;
 9750|  3.31k|      }
 9751|  3.31k|      if (write_data(strm, d, l)) {
 9752|  3.31k|        offset += l;
 9753|       |
 9754|  3.31k|        if (upload_progress && length > 0) {
 9755|  3.31k|          size_t current_written = offset - start_offset;
 9756|  3.31k|          if (!upload_progress(current_written, length)) {
 9757|  3.31k|            ok = false;
 9758|  3.31k|            return false;
 9759|  3.31k|          }
 9760|  3.31k|        }
 9761|  3.31k|      } else {
 9762|  3.31k|        ok = false;
 9763|  3.31k|      }
 9764|  3.31k|    }
 9765|  3.31k|    return ok;
 9766|  3.31k|  };
 9767|       |
 9768|  3.31k|  data_sink.is_writable = [&]() -> bool { return strm.is_peer_alive(); };
 9769|       |
 9770|       |  // The body is framed by `length`, so a provider that reports itself done
 9771|       |  // early has truncated it. Record that and let the short-body check below
 9772|       |  // fail the write, rather than calling the provider again forever.
 9773|  3.31k|  data_sink.done = [&]() { finished = true; };
 9774|       |
 9775|  3.31k|  while (offset < end_offset && !finished && !is_shutting_down()) {
  ------------------
  |  Branch (9775:10): [True: 0, False: 3.31k]
  |  Branch (9775:33): [True: 0, False: 0]
  |  Branch (9775:46): [True: 0, False: 0]
  ------------------
 9776|      0|    auto last_offset = offset;
 9777|       |
 9778|      0|    if (!strm.wait_writable() || !strm.is_peer_alive()) {
  ------------------
  |  Branch (9778:9): [True: 0, False: 0]
  |  Branch (9778:34): [True: 0, False: 0]
  ------------------
 9779|      0|      error = Error::Write;
 9780|      0|      return false;
 9781|      0|    } else if (!content_provider(offset, end_offset - offset, data_sink)) {
  ------------------
  |  Branch (9781:16): [True: 0, False: 0]
  ------------------
 9782|      0|      error = Error::Canceled;
 9783|      0|      return false;
 9784|      0|    } else if (!ok) {
  ------------------
  |  Branch (9784:16): [True: 0, False: 0]
  ------------------
 9785|      0|      error = Error::Write;
 9786|      0|      return false;
 9787|      0|    }
 9788|       |
 9789|       |    // A provider that reports success without writing anything and without
 9790|       |    // reporting itself done gets handed the same offset and length again on
 9791|       |    // the next pass, so it would spin here for as long as the peer stays
 9792|       |    // connected. Treat making no progress as a short body, like done() early.
 9793|      0|    if (!finished && offset == last_offset) {
  ------------------
  |  Branch (9793:9): [True: 0, False: 0]
  |  Branch (9793:22): [True: 0, False: 0]
  ------------------
 9794|      0|      error = Error::Write;
 9795|      0|      return false;
 9796|      0|    }
 9797|      0|  }
 9798|       |
 9799|  3.31k|  if (offset < end_offset) { // done() called early, or is_shutting_down()
  ------------------
  |  Branch (9799:7): [True: 0, False: 3.31k]
  ------------------
 9800|      0|    error = Error::Write;
 9801|      0|    return false;
 9802|      0|  }
 9803|       |
 9804|  3.31k|  error = Error::Success;
 9805|  3.31k|  return true;
 9806|  3.31k|}
_ZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9227|  6.00k|inline bool read_headers(Stream &strm, Headers &headers) {
 9228|  6.00k|  const auto bufsiz = 2048;
 9229|  6.00k|  char buf[bufsiz];
 9230|  6.00k|  stream_line_reader line_reader(strm, buf, bufsiz);
 9231|       |
 9232|  6.00k|  size_t header_count = 0;
 9233|       |
 9234|  27.8k|  for (;;) {
 9235|  27.8k|    if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (9235:9): [True: 408, False: 27.4k]
  ------------------
 9236|       |
 9237|       |    // Check if the line ends with CRLF.
 9238|  27.4k|    auto line_terminator_len = 2;
 9239|  27.4k|    if (line_reader.end_with_crlf()) {
  ------------------
  |  Branch (9239:9): [True: 27.3k, False: 92]
  ------------------
 9240|       |      // Blank line indicates end of headers.
 9241|  27.3k|      if (line_reader.size() == 2) { break; }
  ------------------
  |  Branch (9241:11): [True: 5.18k, False: 22.1k]
  ------------------
 9242|  27.3k|    } else {
 9243|       |#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 9244|       |      // Blank line indicates end of headers.
 9245|       |      if (line_reader.size() == 1) { break; }
 9246|       |      line_terminator_len = 1;
 9247|       |#else
 9248|     92|      continue; // Skip invalid line.
 9249|     92|#endif
 9250|     92|    }
 9251|       |
 9252|  22.1k|    if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
  ------------------
  |  |  127|  22.1k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (9252:9): [True: 3, False: 22.1k]
  ------------------
 9253|       |
 9254|       |    // Check header count limit
 9255|  22.1k|    if (header_count >= CPPHTTPLIB_HEADER_MAX_COUNT) { return false; }
  ------------------
  |  |  131|  22.1k|#define CPPHTTPLIB_HEADER_MAX_COUNT 100
  ------------------
  |  Branch (9255:9): [True: 1, False: 22.1k]
  ------------------
 9256|       |
 9257|       |    // Exclude line terminator
 9258|  22.1k|    auto end = line_reader.ptr() + line_reader.size() - line_terminator_len;
 9259|       |
 9260|  22.1k|    if (!parse_header(line_reader.ptr(), end,
  ------------------
  |  Branch (9260:9): [True: 408, False: 21.7k]
  ------------------
 9261|  22.1k|                      [&](const std::string &key, const std::string &val) {
 9262|  22.1k|                        headers.emplace(key, val);
 9263|  22.1k|                      })) {
 9264|    408|      return false;
 9265|    408|    }
 9266|       |
 9267|  21.7k|    header_count++;
 9268|  21.7k|  }
 9269|       |
 9270|       |  // RFC 9110 Section 8.6: Reject requests with multiple Content-Length
 9271|       |  // headers that have different values to prevent request smuggling.
 9272|  5.18k|  auto cl_range = headers.equal_range("Content-Length");
 9273|  5.18k|  if (cl_range.first != cl_range.second) {
  ------------------
  |  Branch (9273:7): [True: 1.04k, False: 4.14k]
  ------------------
 9274|  1.04k|    const auto &first_val = cl_range.first->second;
 9275|  3.07k|    for (auto it = std::next(cl_range.first); it != cl_range.second; ++it) {
  ------------------
  |  Branch (9275:47): [True: 2.17k, False: 896]
  ------------------
 9276|  2.17k|      if (it->second != first_val) { return false; }
  ------------------
  |  Branch (9276:11): [True: 153, False: 2.02k]
  ------------------
 9277|  2.17k|    }
 9278|  1.04k|  }
 9279|       |
 9280|  5.03k|  return true;
 9281|  5.18k|}
_ZNK7httplib6detail18stream_line_reader13end_with_crlfEv:
 6868|  32.1k|inline bool stream_line_reader::end_with_crlf() const {
 6869|  32.1k|  auto end = ptr() + size();
 6870|  32.1k|  return size() >= 2 && end[-2] == '\r' && end[-1] == '\n';
  ------------------
  |  Branch (6870:10): [True: 32.0k, False: 111]
  |  Branch (6870:25): [True: 31.7k, False: 321]
  |  Branch (6870:44): [True: 31.7k, False: 18]
  ------------------
 6871|  32.1k|}
_ZN7httplib6detail12parse_headerIZNS0_12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS0_11case_ignore8equal_toEEEEUlRKSB_SH_E_EEbPKcSK_T_:
 6531|  22.1k|inline bool parse_header(const char *beg, const char *end, T fn) {
 6532|       |  // Skip trailing spaces and tabs.
 6533|  22.5k|  while (beg < end && is_space_or_tab(end[-1])) {
  ------------------
  |  Branch (6533:10): [True: 22.5k, False: 16]
  |  Branch (6533:23): [True: 409, False: 22.1k]
  ------------------
 6534|    409|    end--;
 6535|    409|  }
 6536|       |
 6537|  22.1k|  auto p = beg;
 6538|   304k|  while (p < end && *p != ':') {
  ------------------
  |  Branch (6538:10): [True: 304k, False: 327]
  |  Branch (6538:21): [True: 282k, False: 21.7k]
  ------------------
 6539|   282k|    p++;
 6540|   282k|  }
 6541|       |
 6542|  22.1k|  auto name = std::string(beg, p);
 6543|  22.1k|  if (!detail::fields::is_field_name(name)) { return false; }
  ------------------
  |  Branch (6543:7): [True: 152, False: 21.9k]
  ------------------
 6544|       |
 6545|  21.9k|  if (p == end) { return false; }
  ------------------
  |  Branch (6545:7): [True: 192, False: 21.7k]
  ------------------
 6546|       |
 6547|  21.7k|  auto key_end = p;
 6548|       |
 6549|  21.7k|  if (*p++ != ':') { return false; }
  ------------------
  |  Branch (6549:7): [True: 0, False: 21.7k]
  ------------------
 6550|       |
 6551|  22.7k|  while (p < end && is_space_or_tab(*p)) {
  ------------------
  |  Branch (6551:10): [True: 5.97k, False: 16.7k]
  |  Branch (6551:21): [True: 956, False: 5.02k]
  ------------------
 6552|    956|    p++;
 6553|    956|  }
 6554|       |
 6555|  21.7k|  if (p <= end) {
  ------------------
  |  Branch (6555:7): [True: 21.7k, False: 0]
  ------------------
 6556|  21.7k|    auto key_len = key_end - beg;
 6557|  21.7k|    if (!key_len) { return false; }
  ------------------
  |  Branch (6557:9): [True: 0, False: 21.7k]
  ------------------
 6558|       |
 6559|  21.7k|    auto key = std::string(beg, key_end);
 6560|  21.7k|    auto val = std::string(p, end);
 6561|       |
 6562|  21.7k|    if (!detail::fields::is_field_value(val)) { return false; }
  ------------------
  |  Branch (6562:9): [True: 64, False: 21.7k]
  ------------------
 6563|       |
 6564|       |    // RFC 9110 §5.5: header field values are opaque octets and MUST NOT be
 6565|       |    // percent-decoded by the recipient. Applications that need to interpret a
 6566|       |    // value as a URI component should call httplib::decode_uri_component()
 6567|       |    // (or decode_path_component()) explicitly.
 6568|  21.7k|    fn(key, val);
 6569|       |
 6570|  21.7k|    return true;
 6571|  21.7k|  }
 6572|       |
 6573|      0|  return false;
 6574|  21.7k|}
_ZZN7httplib6detail12read_headersERNS_6StreamERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEEENKUlRKSA_SG_E_clESG_SG_:
 9261|  21.7k|                      [&](const std::string &key, const std::string &val) {
 9262|  21.7k|                        headers.emplace(key, val);
 9263|  21.7k|                      })) {
_ZN7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE11equal_rangeERKS8_:
 1358|  5.18k|  std::pair<iterator, iterator> equal_range(const std::string &key) {
 1359|  5.18k|    auto i = index_of(key);
 1360|  5.18k|    return i == npos() ? std::make_pair(end(), end())
  ------------------
  |  Branch (1360:12): [True: 4.14k, False: 1.04k]
  ------------------
 1361|  5.18k|                       : std::make_pair(make_iter(i, i), end());
 1362|  5.18k|  }
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tINS2_4pairIS8_S8_EEEptEv:
 1232|  3.22k|    pointer operator->() const { return data_ + idx_; }
_ZN7httplib6detail30has_conflicting_content_lengthERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9551|  1.99k|inline bool has_conflicting_content_length(const Headers &headers) {
 9552|       |  // RFC 9112 §6.3: a message carrying both Transfer-Encoding and a non-zero
 9553|       |  // Content-Length is framed ambiguously. The body readers here delimit it by
 9554|       |  // the transfer coding and drop Content-Length, while an intermediary may do
 9555|       |  // the reverse, so the two disagree on where the body ends and a reused
 9556|       |  // connection is desynchronised (request/response smuggling). Content-Length:
 9557|       |  // 0 is tolerated for compatibility with existing peers.
 9558|  1.99k|  return has_header(headers, "Transfer-Encoding") &&
  ------------------
  |  Branch (9558:10): [True: 1.17k, False: 826]
  ------------------
 9559|  1.17k|         get_header_value_u64(headers, "Content-Length", 0, 0) > 0;
  ------------------
  |  Branch (9559:10): [True: 118, False: 1.05k]
  ------------------
 9560|  1.99k|}
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mm:
 3741|  1.74k|                                   size_t id) {
 3742|  1.74k|  auto dummy = false;
 3743|  1.74k|  return get_header_value_u64(headers, key, def, id, dummy);
 3744|  1.74k|}
_ZN7httplib6detail20get_header_value_u64ERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_mmRb:
 3714|  2.24k|                                   size_t id, bool &is_invalid_value) {
 3715|  2.24k|  is_invalid_value = false;
 3716|  2.24k|  auto rng = headers.equal_range(key);
 3717|  2.24k|  auto it = bounded_next(rng.first, id, rng.second);
 3718|  2.24k|  if (it != rng.second) {
  ------------------
  |  Branch (3718:7): [True: 1.25k, False: 997]
  ------------------
 3719|  1.25k|    if (is_numeric(it->second)) {
  ------------------
  |  Branch (3719:9): [True: 1.04k, False: 212]
  ------------------
 3720|       |      // Parse at size_t width so an out-of-range Content-Length is reported
 3721|       |      // rather than silently saturated/truncated (a value above 2^32 would
 3722|       |      // otherwise wrap to a small framing length on 32-bit builds). Flag it
 3723|       |      // and return SIZE_MAX so the existing oversized-value guards reject it.
 3724|  1.04k|      size_t val = 0;
 3725|  1.04k|      const auto &s = it->second;
 3726|  1.04k|      auto r = from_chars(s.data(), s.data() + s.size(), val);
 3727|  1.04k|      if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (3727:11): [True: 61, False: 979]
  ------------------
 3728|     61|        is_invalid_value = true;
 3729|     61|        return (std::numeric_limits<size_t>::max)();
 3730|     61|      }
 3731|    979|      return val;
 3732|  1.04k|    } else {
 3733|    212|      is_invalid_value = true;
 3734|    212|    }
 3735|  1.25k|  }
 3736|  1.20k|  return def;
 3737|  2.24k|}
_ZN7httplib6detail12bounded_nextINS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS3_4pairIS9_S9_EEEEEET_SI_mSI_:
 3705|  2.24k|template <typename It> inline It bounded_next(It first, size_t n, It last) {
 3706|  2.24k|  for (; n > 0 && first != last; --n) {
  ------------------
  |  Branch (3706:10): [True: 0, False: 2.24k]
  |  Branch (3706:19): [True: 0, False: 0]
  ------------------
 3707|      0|    ++first;
 3708|      0|  }
 3709|  2.24k|  return first;
 3710|  2.24k|}
_ZN7httplib6detail10is_numericERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 3700|  1.25k|inline bool is_numeric(const std::string &str) {
 3701|  1.25k|  return !str.empty() && std::all_of(str.cbegin(), str.cend(), is_ascii_digit);
  ------------------
  |  Branch (3701:10): [True: 1.09k, False: 158]
  |  Branch (3701:26): [True: 1.04k, False: 54]
  ------------------
 3702|  1.25k|}
_ZN7httplib6detail10from_charsImEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  795|  1.04k|                                       T &value, int base = 10) {
  796|  1.04k|  value = 0;
  797|  1.04k|  const char *p = first;
  798|  1.04k|  bool negative = false;
  799|       |
  800|  1.04k|  if (p != last && *p == '-') {
  ------------------
  |  Branch (800:7): [True: 1.04k, False: 0]
  |  Branch (800:20): [True: 0, False: 1.04k]
  ------------------
  801|      0|    negative = true;
  802|      0|    ++p;
  803|      0|  }
  804|  1.04k|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (804:7): [True: 0, False: 1.04k]
  ------------------
  805|       |
  806|  1.04k|  auto radix = static_cast<T>(base);
  807|  1.04k|  T result = 0;
  808|  16.1k|  for (; p != last; ++p) {
  ------------------
  |  Branch (808:10): [True: 15.1k, False: 979]
  ------------------
  809|  15.1k|    char c = *p;
  810|  15.1k|    int digit = -1;
  811|  15.1k|    if (is_ascii_digit(c)) {
  ------------------
  |  Branch (811:9): [True: 15.1k, False: 0]
  ------------------
  812|  15.1k|      digit = c - '0';
  813|  15.1k|    } else if ('a' <= c && c <= 'z') {
  ------------------
  |  Branch (813:16): [True: 0, False: 0]
  |  Branch (813:28): [True: 0, False: 0]
  ------------------
  814|      0|      digit = c - 'a' + 10;
  815|      0|    } else if ('A' <= c && c <= 'Z') {
  ------------------
  |  Branch (815:16): [True: 0, False: 0]
  |  Branch (815:28): [True: 0, False: 0]
  ------------------
  816|      0|      digit = c - 'A' + 10;
  817|      0|    } else {
  818|      0|      break;
  819|      0|    }
  820|       |
  821|  15.1k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (821:9): [True: 0, False: 15.1k]
  |  Branch (821:22): [True: 0, False: 15.1k]
  ------------------
  822|  15.1k|    auto d = static_cast<T>(digit);
  823|  15.1k|    if (result > ((std::numeric_limits<T>::max)() - d) / radix) {
  ------------------
  |  Branch (823:9): [True: 61, False: 15.1k]
  ------------------
  824|     61|      return {p, std::errc::result_out_of_range};
  825|     61|    }
  826|  15.1k|    result = result * radix + d;
  827|  15.1k|  }
  828|       |
  829|    979|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (829:7): [True: 0, False: 979]
  |  Branch (829:22): [True: 0, False: 979]
  |  Branch (829:34): [True: 0, False: 0]
  ------------------
  830|      0|    return {first, std::errc::invalid_argument};
  831|      0|  }
  832|       |
  833|    979|  value = negative ? T(0) - result : result;
  ------------------
  |  Branch (833:11): [True: 0, False: 979]
  ------------------
  834|    979|  return {p, std::errc{}};
  835|    979|}
_ZN7httplib6detail28has_faulty_transfer_encodingINS_8ResponseEEEbRKT_:
 9546|  1.88k|template <typename T> inline bool has_faulty_transfer_encoding(const T &msg) {
 9547|  1.88k|  return msg.has_header("Transfer-Encoding") &&
  ------------------
  |  Branch (9547:10): [True: 1.05k, False: 826]
  ------------------
 9548|  1.05k|         (msg.has_header("Content-Length") || msg.version == "HTTP/1.0");
  ------------------
  |  Branch (9548:11): [True: 58, False: 997]
  |  Branch (9548:47): [True: 518, False: 479]
  ------------------
 9549|  1.88k|}
_ZZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorEENKUlPKcmmmE0_clESA_mmm:
18420|   118k|                      size_t /*len*/) {
18421|   118k|                    assert(res.body.size() + n <= res.body.max_size());
  ------------------
  |  Branch (18421:21): [True: 118k, False: 0]
  ------------------
18422|   118k|                    if (payload_max_length_ > 0 &&
  ------------------
  |  Branch (18422:25): [True: 118k, False: 0]
  ------------------
18423|   118k|                        (res.body.size() >= payload_max_length_ ||
  ------------------
  |  Branch (18423:26): [True: 0, False: 118k]
  ------------------
18424|   118k|                         n > payload_max_length_ - res.body.size())) {
  ------------------
  |  Branch (18424:26): [True: 0, False: 118k]
  ------------------
18425|      0|                      return false;
18426|      0|                    }
18427|   118k|                    res.body.append(buf, n);
18428|   118k|                    return true;
18429|   118k|                  });
_ZNK7httplib8Response10has_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
13136|  4.82k|inline bool Response::has_header(const std::string &key) const {
13137|  4.82k|  return headers.find(key) != headers.end();
13138|  4.82k|}
_ZNK7httplib8Response20get_header_value_u64ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEmm:
13132|    572|                                             size_t id) const {
13133|    572|  return detail::get_header_value_u64(headers, key, def, id);
13134|    572|}
_ZN7httplib6detail12read_contentINS_8ResponseEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEb:
 9620|  1.82k|                  ContentReceiverWithProgress receiver, bool decompress) {
 9621|  1.82k|  bool exceed_payload_max_length = false;
 9622|  1.82k|  return prepare_content_receiver(
 9623|  1.82k|      x, status, std::move(receiver), decompress, payload_max_length,
 9624|  1.82k|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 9625|  1.82k|        auto ret = true;
 9626|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 9627|       |        // wrapper in prepare_content_receiver when the decompressed payload
 9628|       |        // size exceeds the limit.
 9629|       |
 9630|  1.82k|        if (is_chunked_transfer_encoding(x.headers)) {
 9631|  1.82k|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 9632|  1.82k|          if (result == ReadContentResult::Success) {
 9633|  1.82k|            ret = true;
 9634|  1.82k|          } else if (result == ReadContentResult::PayloadTooLarge) {
 9635|  1.82k|            exceed_payload_max_length = true;
 9636|  1.82k|            ret = false;
 9637|  1.82k|          } else {
 9638|  1.82k|            ret = false;
 9639|  1.82k|          }
 9640|  1.82k|        } else if (!has_header(x.headers, "Content-Length")) {
 9641|  1.82k|          auto result =
 9642|  1.82k|              read_content_without_length(strm, payload_max_length, out);
 9643|  1.82k|          if (result == ReadContentResult::Success) {
 9644|  1.82k|            ret = true;
 9645|  1.82k|          } else if (result == ReadContentResult::PayloadTooLarge) {
 9646|  1.82k|            exceed_payload_max_length = true;
 9647|  1.82k|            ret = false;
 9648|  1.82k|          } else {
 9649|  1.82k|            ret = false;
 9650|  1.82k|          }
 9651|  1.82k|        } else {
 9652|  1.82k|          auto is_invalid_value = false;
 9653|  1.82k|          auto len = get_header_value_u64(x.headers, "Content-Length",
 9654|  1.82k|                                          (std::numeric_limits<size_t>::max)(),
 9655|  1.82k|                                          0, is_invalid_value);
 9656|       |
 9657|  1.82k|          if (is_invalid_value) {
 9658|  1.82k|            ret = false;
 9659|  1.82k|          } else if (len > 0) {
 9660|  1.82k|            auto result = read_content_with_length(
 9661|  1.82k|                strm, len, std::move(progress), out, payload_max_length);
 9662|  1.82k|            ret = (result == ReadContentResult::Success);
 9663|  1.82k|            if (result == ReadContentResult::PayloadTooLarge) {
 9664|  1.82k|              exceed_payload_max_length = true;
 9665|  1.82k|            }
 9666|  1.82k|          }
 9667|  1.82k|        }
 9668|       |
 9669|  1.82k|        if (!ret) {
 9670|  1.82k|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
 9671|  1.82k|                                             : StatusCode::BadRequest_400;
 9672|  1.82k|        }
 9673|  1.82k|        return ret;
 9674|  1.82k|      });
 9675|  1.82k|}
_ZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_:
 9566|  1.82k|                              bool &exceed_payload_max_length, U callback) {
 9567|  1.82k|  if (decompress) {
  ------------------
  |  Branch (9567:7): [True: 1.82k, False: 0]
  ------------------
 9568|  1.82k|    auto encoding = get_combined_header_value(x.headers, "Content-Encoding");
 9569|  1.82k|    std::unique_ptr<decompressor> decompressor;
 9570|       |
 9571|  1.82k|    if (!encoding.empty()) {
  ------------------
  |  Branch (9571:9): [True: 263, False: 1.55k]
  ------------------
 9572|       |      // A coding we know about but were not built with is an error. An
 9573|       |      // unrecognized coding (including "identity") is left alone and the
 9574|       |      // payload is passed through as-is, since some servers misuse the header,
 9575|       |      // e.g. by sending a character set such as "Content-Encoding: UTF-8".
 9576|    263|      decompressor = detail::create_decompressor(encoding);
 9577|    263|      if (!decompressor && detail::is_known_content_encoding(encoding)) {
  ------------------
  |  Branch (9577:11): [True: 107, False: 156]
  |  Branch (9577:28): [True: 2, False: 105]
  ------------------
 9578|      2|        status = StatusCode::UnsupportedMediaType_415;
 9579|      2|        return false;
 9580|      2|      }
 9581|    263|    }
 9582|       |
 9583|  1.81k|    if (decompressor) {
  ------------------
  |  Branch (9583:9): [True: 156, False: 1.66k]
  ------------------
 9584|    156|      if (decompressor->is_valid()) {
  ------------------
  |  Branch (9584:11): [True: 156, False: 0]
  ------------------
 9585|    156|        size_t decompressed_size = 0;
 9586|    156|        ContentReceiverWithProgress out = [&](const char *buf, size_t n,
 9587|    156|                                              size_t off, size_t len) {
 9588|    156|          return decompressor->decompress(
 9589|    156|              buf, n, [&](const char *buf2, size_t n2) {
 9590|       |                // Guard against zip-bomb: check
 9591|       |                // decompressed size against limit.
 9592|    156|                if (payload_max_length > 0 &&
 9593|    156|                    (decompressed_size >= payload_max_length ||
 9594|    156|                     n2 > payload_max_length - decompressed_size)) {
 9595|    156|                  exceed_payload_max_length = true;
 9596|    156|                  return false;
 9597|    156|                }
 9598|    156|                decompressed_size += n2;
 9599|    156|                return receiver(buf2, n2, off, len);
 9600|    156|              });
 9601|    156|        };
 9602|    156|        return callback(std::move(out));
 9603|    156|      } else {
 9604|      0|        status = StatusCode::InternalServerError_500;
 9605|      0|        return false;
 9606|      0|      }
 9607|    156|    }
 9608|  1.81k|  }
 9609|       |
 9610|  1.66k|  ContentReceiverWithProgress out = [&](const char *buf, size_t n, size_t off,
 9611|  1.66k|                                        size_t len) {
 9612|  1.66k|    return receiver(buf, n, off, len);
 9613|  1.66k|  };
 9614|  1.66k|  return callback(std::move(out));
 9615|  1.82k|}
_ZN7httplib6detail25get_combined_header_valueERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKS8_:
 9168|  1.97k|                                             const std::string &key) {
 9169|  1.97k|  std::string combined;
 9170|  1.97k|  auto rng = headers.equal_range(key);
 9171|  3.22k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9171:29): [True: 1.24k, False: 1.97k]
  ------------------
 9172|       |    // RFC 9110 Section 5.6.1.2: a recipient has to parse and ignore empty list
 9173|       |    // elements, so an empty field line must not contribute a bare comma to the
 9174|       |    // combined value.
 9175|  1.24k|    if (it->second.empty()) { continue; }
  ------------------
  |  Branch (9175:9): [True: 119, False: 1.12k]
  ------------------
 9176|  1.12k|    if (!combined.empty()) { combined += ", "; }
  ------------------
  |  Branch (9176:9): [True: 862, False: 263]
  ------------------
 9177|  1.12k|    combined += it->second;
 9178|  1.12k|  }
 9179|  1.97k|  return combined;
 9180|  1.97k|}
_ZN7httplib6detail19create_decompressorERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9091|    263|create_decompressor(const std::string &encoding) {
 9092|    263|  std::unique_ptr<decompressor> decompressor;
 9093|       |
 9094|    263|  if (is_zlib_encoding(encoding)) {
  ------------------
  |  Branch (9094:7): [True: 156, False: 107]
  ------------------
 9095|    156|#ifdef CPPHTTPLIB_ZLIB_SUPPORT
 9096|    156|    decompressor = detail::make_unique<gzip_decompressor>();
 9097|    156|#endif
 9098|    156|  } else if (is_brotli_encoding(encoding)) {
  ------------------
  |  Branch (9098:14): [True: 1, False: 106]
  ------------------
 9099|       |#ifdef CPPHTTPLIB_BROTLI_SUPPORT
 9100|       |    decompressor = detail::make_unique<brotli_decompressor>();
 9101|       |#endif
 9102|    106|  } else if (is_zstd_encoding(encoding)) {
  ------------------
  |  Branch (9102:14): [True: 1, False: 105]
  ------------------
 9103|       |#ifdef CPPHTTPLIB_ZSTD_SUPPORT
 9104|       |    decompressor = detail::make_unique<zstd_decompressor>();
 9105|       |#endif
 9106|      1|  }
 9107|       |
 9108|    263|  return decompressor;
 9109|    263|}
_ZN7httplib6detail16is_zlib_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9070|    370|inline bool is_zlib_encoding(const std::string &encoding) {
 9071|    370|  return case_ignore::equal(encoding, "gzip") ||
  ------------------
  |  Branch (9071:10): [True: 28, False: 342]
  ------------------
 9072|    342|         case_ignore::equal(encoding, "deflate");
  ------------------
  |  Branch (9072:10): [True: 128, False: 214]
  ------------------
 9073|    370|}
_ZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|    582|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|    582|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 80, False: 502]
  ------------------
  729|     80|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 30, False: 50]
  ------------------
  730|     80|           return to_lower(ca) == to_lower(cb);
  731|     80|         });
  732|    582|}
_ZZN7httplib6detail11case_ignore5equalILm5EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|    192|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|    192|           return to_lower(ca) == to_lower(cb);
  731|    192|         });
_ZN7httplib6detail11case_ignore5equalILm8EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|  1.39k|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|  1.39k|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 963, False: 434]
  ------------------
  729|    963|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 922, False: 41]
  ------------------
  730|    963|           return to_lower(ca) == to_lower(cb);
  731|    963|         });
  732|  1.39k|}
_ZZN7httplib6detail11case_ignore5equalILm8EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|  6.58k|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|  6.58k|           return to_lower(ca) == to_lower(cb);
  731|  6.58k|         });
_ZN7httplib6detail11make_uniqueINS0_17gzip_decompressorEJEEENSt3__19enable_ifIXntsr3std8is_arrayIT_EE5valueENS3_10unique_ptrIS5_NS3_14default_deleteIS5_EEEEE4typeEDpOT0_:
  658|    156|make_unique(Args &&...args) {
  659|    156|  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  660|    156|}
_ZN7httplib6detail17gzip_decompressorC2Ev:
 8865|    156|inline gzip_decompressor::gzip_decompressor() {
 8866|    156|  std::memset(&strm_, 0, sizeof(strm_));
 8867|    156|  strm_.zalloc = Z_NULL;
 8868|    156|  strm_.zfree = Z_NULL;
 8869|    156|  strm_.opaque = Z_NULL;
 8870|       |
 8871|       |  // 15 is the value of wbits, which should be at the maximum possible value
 8872|       |  // to ensure that any gzip stream can be decoded. The offset of 32 specifies
 8873|       |  // that the stream type should be automatically detected either gzip or
 8874|       |  // deflate.
 8875|    156|  is_valid_ = inflateInit2(&strm_, 32 + 15) == Z_OK;
 8876|    156|}
_ZN7httplib6detail18is_brotli_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9075|    214|inline bool is_brotli_encoding(const std::string &encoding) {
 9076|    214|  return case_ignore::equal(encoding, "br");
 9077|    214|}
_ZN7httplib6detail11case_ignore5equalILm3EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__Kc:
  727|    214|inline bool equal(const std::string &a, const char (&b)[N]) {
  728|    214|  return a.size() == N - 1 &&
  ------------------
  |  Branch (728:10): [True: 26, False: 188]
  ------------------
  729|     26|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  ------------------
  |  Branch (729:10): [True: 2, False: 24]
  ------------------
  730|     26|           return to_lower(ca) == to_lower(cb);
  731|     26|         });
  732|    214|}
_ZZN7httplib6detail11case_ignore5equalILm3EEEbRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERAT__KcENKUlccE_clEcc:
  729|     34|         std::equal(a.begin(), a.end(), b, [](char ca, char cb) {
  730|     34|           return to_lower(ca) == to_lower(cb);
  731|     34|         });
_ZN7httplib6detail16is_zstd_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9079|    212|inline bool is_zstd_encoding(const std::string &encoding) {
 9080|    212|  return case_ignore::equal(encoding, "zstd");
 9081|    212|}
_ZN7httplib6detail25is_known_content_encodingERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 9085|    107|inline bool is_known_content_encoding(const std::string &encoding) {
 9086|    107|  return is_zlib_encoding(encoding) || is_brotli_encoding(encoding) ||
  ------------------
  |  Branch (9086:10): [True: 0, False: 107]
  |  Branch (9086:40): [True: 1, False: 106]
  ------------------
 9087|    106|         is_zstd_encoding(encoding);
  ------------------
  |  Branch (9087:10): [True: 1, False: 105]
  ------------------
 9088|    107|}
_ZZN7httplib6detail24prepare_content_receiverINS_8ResponseEZNS0_12read_contentIS2_EEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENSA_IFbPKcmmmEEEbEUlRKSG_E_EEbS7_S8_SG_bmRbT0_ENKUlSE_mmmE_clESE_mmm:
 9587|  2.83k|                                              size_t off, size_t len) {
 9588|  2.83k|          return decompressor->decompress(
 9589|  2.83k|              buf, n, [&](const char *buf2, size_t n2) {
 9590|       |                // Guard against zip-bomb: check
 9591|       |                // decompressed size against limit.
 9592|  2.83k|                if (payload_max_length > 0 &&
 9593|  2.83k|                    (decompressed_size >= payload_max_length ||
 9594|  2.83k|                     n2 > payload_max_length - decompressed_size)) {
 9595|  2.83k|                  exceed_payload_max_length = true;
 9596|  2.83k|                  return false;
 9597|  2.83k|                }
 9598|  2.83k|                decompressed_size += n2;
 9599|  2.83k|                return receiver(buf2, n2, off, len);
 9600|  2.83k|              });
 9601|  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:
 9589|   115k|              buf, n, [&](const char *buf2, size_t n2) {
 9590|       |                // Guard against zip-bomb: check
 9591|       |                // decompressed size against limit.
 9592|   115k|                if (payload_max_length > 0 &&
  ------------------
  |  Branch (9592:21): [True: 115k, False: 0]
  ------------------
 9593|   115k|                    (decompressed_size >= payload_max_length ||
  ------------------
  |  Branch (9593:22): [True: 1, False: 115k]
  ------------------
 9594|   115k|                     n2 > payload_max_length - decompressed_size)) {
  ------------------
  |  Branch (9594:22): [True: 13, False: 115k]
  ------------------
 9595|     14|                  exceed_payload_max_length = true;
 9596|     14|                  return false;
 9597|     14|                }
 9598|   115k|                decompressed_size += n2;
 9599|   115k|                return receiver(buf2, n2, off, len);
 9600|   115k|              });
_ZZN7httplib6detail12read_contentINS_8ResponseEEEbRNS_6StreamERT_mRiNSt3__18functionIFbmmEEENS9_IFbPKcmmmEEEbENKUlRKSF_E_clESH_:
 9624|  1.81k|      exceed_payload_max_length, [&](const ContentReceiverWithProgress &out) {
 9625|  1.81k|        auto ret = true;
 9626|       |        // Note: exceed_payload_max_length may also be set by the decompressor
 9627|       |        // wrapper in prepare_content_receiver when the decompressed payload
 9628|       |        // size exceeds the limit.
 9629|       |
 9630|  1.81k|        if (is_chunked_transfer_encoding(x.headers)) {
  ------------------
  |  Branch (9630:13): [True: 794, False: 1.02k]
  ------------------
 9631|    794|          auto result = read_content_chunked(strm, x, payload_max_length, out);
 9632|    794|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (9632:15): [True: 1, False: 793]
  ------------------
 9633|      1|            ret = true;
 9634|    793|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9634:22): [True: 0, False: 793]
  ------------------
 9635|      0|            exceed_payload_max_length = true;
 9636|      0|            ret = false;
 9637|    793|          } else {
 9638|    793|            ret = false;
 9639|    793|          }
 9640|  1.02k|        } else if (!has_header(x.headers, "Content-Length")) {
  ------------------
  |  Branch (9640:20): [True: 520, False: 504]
  ------------------
 9641|    520|          auto result =
 9642|    520|              read_content_without_length(strm, payload_max_length, out);
 9643|    520|          if (result == ReadContentResult::Success) {
  ------------------
  |  Branch (9643:15): [True: 491, False: 29]
  ------------------
 9644|    491|            ret = true;
 9645|    491|          } else if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9645:22): [True: 0, False: 29]
  ------------------
 9646|      0|            exceed_payload_max_length = true;
 9647|      0|            ret = false;
 9648|     29|          } else {
 9649|     29|            ret = false;
 9650|     29|          }
 9651|    520|        } else {
 9652|    504|          auto is_invalid_value = false;
 9653|    504|          auto len = get_header_value_u64(x.headers, "Content-Length",
 9654|    504|                                          (std::numeric_limits<size_t>::max)(),
 9655|    504|                                          0, is_invalid_value);
 9656|       |
 9657|    504|          if (is_invalid_value) {
  ------------------
  |  Branch (9657:15): [True: 81, False: 423]
  ------------------
 9658|     81|            ret = false;
 9659|    423|          } else if (len > 0) {
  ------------------
  |  Branch (9659:22): [True: 409, False: 14]
  ------------------
 9660|    409|            auto result = read_content_with_length(
 9661|    409|                strm, len, std::move(progress), out, payload_max_length);
 9662|    409|            ret = (result == ReadContentResult::Success);
 9663|    409|            if (result == ReadContentResult::PayloadTooLarge) {
  ------------------
  |  Branch (9663:17): [True: 0, False: 409]
  ------------------
 9664|      0|              exceed_payload_max_length = true;
 9665|      0|            }
 9666|    409|          }
 9667|    504|        }
 9668|       |
 9669|  1.81k|        if (!ret) {
  ------------------
  |  Branch (9669:13): [True: 1.30k, False: 509]
  ------------------
 9670|  1.30k|          status = exceed_payload_max_length ? StatusCode::PayloadTooLarge_413
  ------------------
  |  Branch (9670:20): [True: 14, False: 1.29k]
  ------------------
 9671|  1.30k|                                             : StatusCode::BadRequest_400;
 9672|  1.30k|        }
 9673|  1.81k|        return ret;
 9674|  1.81k|      });
_ZN7httplib6detail28is_chunked_transfer_encodingERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEE:
 9512|  1.81k|inline bool is_chunked_transfer_encoding(const Headers &headers) {
 9513|       |  // RFC 9112 6.1: a message is framed with the chunked coding when "chunked"
 9514|       |  // is the final transfer coding. A single field value may list several
 9515|       |  // codings ("gzip, chunked"), and RFC 9110 5.3 lets that list be split across
 9516|       |  // several Transfer-Encoding lines, which combine into one comma-separated
 9517|       |  // list in the order the lines were received. Headers preserves that order,
 9518|       |  // so the final coding is the last token of the last line. Match it
 9519|       |  // case-insensitively rather than comparing the whole value against
 9520|       |  // "chunked".
 9521|       |  //
 9522|       |  // Security: reading a chunked message as unframed leaves its body in the
 9523|       |  // socket, where a keep-alive connection parses it as a smuggled request.
 9524|       |  // Server::process_request() answers 400 and closes when the final coding is
 9525|       |  // not chunked, so a request whose framing cannot be determined never
 9526|       |  // reaches the "no body" path.
 9527|  1.81k|  auto rng = headers.equal_range("Transfer-Encoding");
 9528|  1.81k|  if (rng.first == rng.second) { return false; }
  ------------------
  |  Branch (9528:7): [True: 763, False: 1.05k]
  ------------------
 9529|       |
 9530|       |  // Cleared per line, so a trailing line carrying no coding at all leaves the
 9531|       |  // combined list ending in nothing rather than inheriting the line before it.
 9532|  1.05k|  std::string last_coding;
 9533|       |
 9534|  2.52k|  for (auto it = rng.first; it != rng.second; ++it) {
  ------------------
  |  Branch (9534:29): [True: 1.46k, False: 1.05k]
  ------------------
 9535|  1.46k|    const auto &value = it->second;
 9536|  1.46k|    last_coding.clear();
 9537|  1.46k|    split(value.data(), value.data() + value.size(), ',',
 9538|  1.46k|          [&](const char *b, const char *e) { last_coding.assign(b, e); });
 9539|  1.46k|  }
 9540|       |
 9541|  1.05k|  return case_ignore::equal(last_coding, "chunked");
 9542|  1.81k|}
_ZNK7httplib6detail26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEE10iterator_tIKNS2_4pairIS8_S8_EEEeqISF_EEbRKNSC_IT_EE:
 1270|  1.81k|    template <typename U> bool operator==(const iterator_t<U> &rhs) const {
 1271|  1.81k|      return idx_ == rhs.idx_;
 1272|  1.81k|    }
_ZZN7httplib6detail28is_chunked_transfer_encodingERKNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS0_11case_ignore8equal_toEEEENKUlPKcSF_E_clESF_SF_:
 9538|  7.73k|          [&](const char *b, const char *e) { last_coding.assign(b, e); });
_ZN7httplib6detail20read_content_chunkedINS_8ResponseEEENS0_17ReadContentResultERNS_6StreamERT_mNSt3__18functionIFbPKcmmmEEE:
 9479|    794|                                              ContentReceiverWithProgress out) {
 9480|    794|  detail::ChunkedDecoder dec(strm);
 9481|       |
 9482|    794|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 9483|    794|  size_t total_len = 0;
 9484|       |
 9485|  5.32k|  for (;;) {
 9486|  5.32k|    size_t chunk_offset = 0;
 9487|  5.32k|    size_t chunk_total = 0;
 9488|  5.32k|    auto n = dec.read_payload(buf, sizeof(buf), chunk_offset, chunk_total);
 9489|  5.32k|    if (n < 0) { return ReadContentResult::Error; }
  ------------------
  |  Branch (9489:9): [True: 583, False: 4.74k]
  ------------------
 9490|       |
 9491|  4.74k|    if (n == 0) {
  ------------------
  |  Branch (9491:9): [True: 209, False: 4.53k]
  ------------------
 9492|    209|      if (!dec.parse_trailers_into(x.trailers, x.headers)) {
  ------------------
  |  Branch (9492:11): [True: 208, False: 1]
  ------------------
 9493|    208|        return ReadContentResult::Error;
 9494|    208|      }
 9495|      1|      return ReadContentResult::Success;
 9496|    209|    }
 9497|       |
 9498|  4.53k|    if (payload_max_length > 0 &&
  ------------------
  |  Branch (9498:9): [True: 4.53k, False: 0]
  ------------------
 9499|  4.53k|        (total_len > payload_max_length ||
  ------------------
  |  Branch (9499:10): [True: 0, False: 4.53k]
  ------------------
 9500|  4.53k|         payload_max_length - total_len < static_cast<size_t>(n))) {
  ------------------
  |  Branch (9500:10): [True: 0, False: 4.53k]
  ------------------
 9501|      0|      return ReadContentResult::PayloadTooLarge;
 9502|      0|    }
 9503|       |
 9504|  4.53k|    if (!out(buf, static_cast<size_t>(n), chunk_offset, chunk_total)) {
  ------------------
  |  Branch (9504:9): [True: 2, False: 4.53k]
  ------------------
 9505|      2|      return ReadContentResult::Error;
 9506|      2|    }
 9507|       |
 9508|  4.53k|    total_len += static_cast<size_t>(n);
 9509|  4.53k|  }
 9510|    794|}
_ZN7httplib6detail14ChunkedDecoderC2ERNS_6StreamE:
17456|    794|inline ChunkedDecoder::ChunkedDecoder(Stream &s) : strm(s) {}
_ZN7httplib6detail14ChunkedDecoder12read_payloadEPcmRmS3_:
17460|  5.32k|                                            size_t &out_chunk_total) {
17461|  5.32k|  if (finished) { return 0; }
  ------------------
  |  Branch (17461:7): [True: 0, False: 5.32k]
  ------------------
17462|       |
17463|  5.32k|  if (chunk_remaining == 0) {
  ------------------
  |  Branch (17463:7): [True: 4.77k, False: 553]
  ------------------
17464|  4.77k|    stream_line_reader lr(strm, line_buf, sizeof(line_buf));
17465|  4.77k|    if (!lr.getline()) { return -1; }
  ------------------
  |  Branch (17465:9): [True: 19, False: 4.75k]
  ------------------
17466|       |
17467|       |    // Everything below is bounded by eol rather than by the buffer's NUL, so
17468|       |    // the line terminator is never mistaken for line content.
17469|  4.75k|    const char *eol = lr.ptr() + lr.size();
17470|  4.75k|    if (lr.end_with_crlf()) {
  ------------------
  |  Branch (17470:9): [True: 4.39k, False: 358]
  ------------------
17471|  4.39k|      eol -= 2;
17472|  4.39k|    } else if (eol != lr.ptr() && eol[-1] == '\n') {
  ------------------
  |  Branch (17472:16): [True: 358, False: 0]
  |  Branch (17472:35): [True: 8, False: 350]
  ------------------
17473|       |      // Only reachable under CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR, where
17474|       |      // getline() ends the line on a bare LF. That LF is the terminator, so it
17475|       |      // has to come off here or the check below would reject the line.
17476|      8|      eol -= 1;
17477|      8|    }
17478|       |
17479|       |    // RFC 9112 §7.1: chunk-size = 1*HEXDIG
17480|  4.75k|    const char *p = lr.ptr();
17481|  4.75k|    int v = 0;
17482|  4.75k|    if (p == eol || !is_hex(*p, v)) { return -1; }
  ------------------
  |  Branch (17482:9): [True: 9, False: 4.74k]
  |  Branch (17482:21): [True: 35, False: 4.71k]
  ------------------
17483|       |
17484|  4.71k|    size_t chunk_len = 0;
17485|  4.71k|    constexpr size_t chunk_len_max = (std::numeric_limits<size_t>::max)();
17486|  13.6k|    for (; p < eol && is_hex(*p, v); ++p) {
  ------------------
  |  Branch (17486:12): [True: 9.49k, False: 4.17k]
  |  Branch (17486:23): [True: 8.97k, False: 521]
  ------------------
17487|  8.97k|      if (chunk_len > (chunk_len_max >> 4)) { return -1; }
  ------------------
  |  Branch (17487:11): [True: 12, False: 8.96k]
  ------------------
17488|  8.96k|      chunk_len = (chunk_len << 4) | static_cast<size_t>(v);
17489|  8.96k|    }
17490|       |
17491|  6.06k|    while (p < eol && is_space_or_tab(*p)) {
  ------------------
  |  Branch (17491:12): [True: 1.87k, False: 4.19k]
  |  Branch (17491:23): [True: 1.36k, False: 505]
  ------------------
17492|  1.36k|      ++p;
17493|  1.36k|    }
17494|       |
17495|       |    // RFC 9112 §7.1.1: only a chunk-ext may sit between the size and the line
17496|       |    // terminator, and it is built from tokens and quoted-strings, so it never
17497|       |    // holds a CR, LF or any other control character. getline() reads up to the
17498|       |    // CRLF, so a bare LF left in here would be swallowed as extension text
17499|       |    // while an intermediary that ends the line on it delimits the chunks
17500|       |    // differently, and the two disagree on where the body ends (request
17501|       |    // smuggling).
17502|  4.69k|    if (p < eol && *p != ';') { return -1; }
  ------------------
  |  Branch (17502:9): [True: 505, False: 4.19k]
  |  Branch (17502:20): [True: 30, False: 475]
  ------------------
17503|   213k|    for (; p < eol; ++p) {
  ------------------
  |  Branch (17503:12): [True: 208k, False: 4.66k]
  ------------------
17504|   208k|      if (!is_space_or_tab(*p) && !fields::is_field_vchar(*p)) { return -1; }
  ------------------
  |  Branch (17504:11): [True: 199k, False: 9.19k]
  |  Branch (17504:35): [True: 4, False: 199k]
  ------------------
17505|   208k|    }
17506|       |
17507|       |    // The bytes around the data are no payload, so they are counted on their
17508|       |    // own, as Go does: each chunk may spend 16 bytes and twice its data on
17509|       |    // them, which lets a stream send a byte at a time, and what goes past that
17510|       |    // in padding, leading zeros and extensions builds up to one header field.
17511|  4.66k|    overhead += lr.size() + 2;
17512|  4.66k|    overhead = overhead > 16 ? overhead - 16 : 0;
  ------------------
  |  Branch (17512:16): [True: 596, False: 4.06k]
  ------------------
17513|  4.66k|    overhead = chunk_len > overhead / 2 ? 0 : overhead - 2 * chunk_len;
  ------------------
  |  Branch (17513:16): [True: 4.06k, False: 596]
  ------------------
17514|  4.66k|    if (overhead > CPPHTTPLIB_HEADER_MAX_LENGTH) { return -1; }
  ------------------
  |  |  127|  4.66k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (17514:9): [True: 4, False: 4.66k]
  ------------------
17515|       |
17516|  4.66k|    if (chunk_len == 0) {
  ------------------
  |  Branch (17516:9): [True: 209, False: 4.45k]
  ------------------
17517|    209|      chunk_remaining = 0;
17518|    209|      finished = true;
17519|    209|      out_chunk_offset = 0;
17520|    209|      out_chunk_total = 0;
17521|    209|      return 0;
17522|    209|    }
17523|       |
17524|  4.45k|    chunk_remaining = chunk_len;
17525|  4.45k|    last_chunk_total = chunk_remaining;
17526|  4.45k|    last_chunk_offset = 0;
17527|  4.45k|  }
17528|       |
17529|  5.00k|  auto to_read = (std::min)(chunk_remaining, len);
17530|  5.00k|  auto n = strm.read(buf, to_read);
17531|  5.00k|  if (n <= 0) { return -1; }
  ------------------
  |  Branch (17531:7): [True: 441, False: 4.56k]
  ------------------
17532|       |
17533|  4.56k|  auto offset_before = last_chunk_offset;
17534|  4.56k|  last_chunk_offset += static_cast<size_t>(n);
17535|  4.56k|  chunk_remaining -= static_cast<size_t>(n);
17536|       |
17537|  4.56k|  out_chunk_offset = offset_before;
17538|  4.56k|  out_chunk_total = last_chunk_total;
17539|       |
17540|  4.56k|  if (chunk_remaining == 0) {
  ------------------
  |  Branch (17540:7): [True: 4.00k, False: 555]
  ------------------
17541|  4.00k|    stream_line_reader lr(strm, line_buf, sizeof(line_buf));
17542|  4.00k|    if (!lr.getline()) { return -1; }
  ------------------
  |  Branch (17542:9): [True: 5, False: 4.00k]
  ------------------
17543|  4.00k|    if (std::strcmp(lr.ptr(), "\r\n") != 0) { return -1; }
  ------------------
  |  Branch (17543:9): [True: 24, False: 3.97k]
  ------------------
17544|  4.00k|  }
17545|       |
17546|  4.53k|  return n;
17547|  4.56k|}
_ZN7httplib6detail14ChunkedDecoder19parse_trailers_intoERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSC_:
17550|    209|                                                const Headers &src_headers) {
17551|    209|  stream_line_reader lr(strm, line_buf, sizeof(line_buf));
17552|    209|  if (!lr.getline()) { return false; }
  ------------------
  |  Branch (17552:7): [True: 53, False: 156]
  ------------------
17553|    156|  return parse_trailers(lr, dest, src_headers);
17554|    209|}
_ZN7httplib6detail14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSD_:
 6577|    156|                           const Headers &src_headers) {
 6578|       |  // NOTE: In RFC 9112, '7.1 Chunked Transfer Coding' mentions "The chunked
 6579|       |  // transfer coding is complete when a chunk with a chunk-size of zero is
 6580|       |  // received, possibly followed by a trailer section, and finally terminated by
 6581|       |  // an empty line". https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
 6582|       |  //
 6583|       |  // In '7.1.3. Decoding Chunked', however, the pseudo-code in the section
 6584|       |  // doesn't care for the existence of the final CRLF. In other words, it seems
 6585|       |  // to be ok whether the final CRLF exists or not in the chunked data.
 6586|       |  // https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1.3
 6587|       |  //
 6588|       |  // According to the reference code in RFC 9112, cpp-httplib now allows
 6589|       |  // chunked transfer coding data without the final CRLF.
 6590|       |
 6591|       |  // RFC 7230 Section 4.1.2 - Headers prohibited in trailers
 6592|    156|  thread_local case_ignore::unordered_set<std::string> prohibited_trailers = {
 6593|    156|      "transfer-encoding",
 6594|    156|      "content-length",
 6595|    156|      "host",
 6596|    156|      "authorization",
 6597|    156|      "www-authenticate",
 6598|    156|      "proxy-authenticate",
 6599|    156|      "proxy-authorization",
 6600|    156|      "cookie",
 6601|    156|      "set-cookie",
 6602|    156|      "cache-control",
 6603|    156|      "expect",
 6604|    156|      "max-forwards",
 6605|    156|      "pragma",
 6606|    156|      "range",
 6607|    156|      "te",
 6608|    156|      "age",
 6609|    156|      "expires",
 6610|    156|      "date",
 6611|    156|      "location",
 6612|    156|      "retry-after",
 6613|    156|      "vary",
 6614|    156|      "warning",
 6615|    156|      "content-encoding",
 6616|    156|      "content-type",
 6617|    156|      "content-range",
 6618|    156|      "trailer"};
 6619|       |
 6620|    156|  case_ignore::unordered_set<std::string> declared_trailers;
 6621|    156|  auto trailer_header = get_combined_header_value(src_headers, "Trailer");
 6622|    156|  if (!trailer_header.empty()) {
  ------------------
  |  Branch (6622:7): [True: 0, False: 156]
  ------------------
 6623|       |    // split() trims each token and skips empty ones, so the name arrives ready
 6624|       |    // to look up.
 6625|      0|    split(trailer_header.data(), trailer_header.data() + trailer_header.size(),
 6626|      0|          ',', [&](const char *b, const char *e) {
 6627|       |            // A legitimate message declares only a handful of trailers. Cap the
 6628|       |            // set so a peer cannot grow it without bound: an oversized set only
 6629|       |            // arises from an attempt to force many colliding names into
 6630|       |            // quadratic lookups (case_ignore::hash is unkeyed).
 6631|      0|            if (declared_trailers.size() >= CPPHTTPLIB_HEADER_MAX_COUNT) {
 6632|      0|              return;
 6633|      0|            }
 6634|      0|            std::string key(b, e);
 6635|      0|            if (prohibited_trailers.find(key) == prohibited_trailers.end()) {
 6636|      0|              declared_trailers.insert(key);
 6637|      0|            }
 6638|      0|          });
 6639|      0|  }
 6640|       |
 6641|    156|  size_t trailer_header_count = 0;
 6642|  1.25k|  while (strcmp(line_reader.ptr(), "\r\n") != 0) {
  ------------------
  |  Branch (6642:10): [True: 1.24k, False: 1]
  ------------------
 6643|  1.24k|    if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
  ------------------
  |  |  127|  1.24k|#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
  ------------------
  |  Branch (6643:9): [True: 2, False: 1.24k]
  ------------------
 6644|       |    // Count every received trailer field, not only the declared ones stored in
 6645|       |    // dest, so undeclared fields cannot keep this loop running past the limit.
 6646|  1.24k|    if (trailer_header_count >= CPPHTTPLIB_HEADER_MAX_COUNT) { return false; }
  ------------------
  |  |  131|  1.24k|#define CPPHTTPLIB_HEADER_MAX_COUNT 100
  ------------------
  |  Branch (6646:9): [True: 1, False: 1.24k]
  ------------------
 6647|       |
 6648|  1.24k|    constexpr auto line_terminator_len = 2;
 6649|  1.24k|    auto line_beg = line_reader.ptr();
 6650|  1.24k|    auto line_end =
 6651|  1.24k|        line_reader.ptr() + line_reader.size() - line_terminator_len;
 6652|       |
 6653|  1.24k|    if (!parse_header(line_beg, line_end,
  ------------------
  |  Branch (6653:9): [True: 113, False: 1.13k]
  ------------------
 6654|  1.24k|                      [&](const std::string &key, const std::string &val) {
 6655|  1.24k|                        if (declared_trailers.find(key) !=
 6656|  1.24k|                            declared_trailers.end()) {
 6657|  1.24k|                          dest.emplace(key, val);
 6658|  1.24k|                        }
 6659|  1.24k|                      })) {
 6660|    113|      return false;
 6661|    113|    }
 6662|       |
 6663|  1.13k|    trailer_header_count++;
 6664|       |
 6665|  1.13k|    if (!line_reader.getline()) { return false; }
  ------------------
  |  Branch (6665:9): [True: 39, False: 1.09k]
  ------------------
 6666|  1.13k|  }
 6667|       |
 6668|      1|  return true;
 6669|    156|}
_ZNK7httplib6detail11case_ignore4hashclERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE:
  741|     26|  size_t operator()(const std::string &key) const {
  742|     26|    size_t h = 0;
  743|    253|    for (auto c : key) {
  ------------------
  |  Branch (743:17): [True: 253, False: 26]
  ------------------
  744|       |      // Unsets the 6 high bits of h, therefore no overflow happens
  745|    253|      h = (((std::numeric_limits<size_t>::max)() >> 6) & h * 33) ^
  746|    253|          static_cast<unsigned char>(to_lower(c));
  747|    253|    }
  748|     26|    return h;
  749|     26|  }
_ZN7httplib6detail12parse_headerIZNS0_14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSE_EUlRKSB_SJ_E_EEbPKcSM_T_:
 6531|  1.24k|inline bool parse_header(const char *beg, const char *end, T fn) {
 6532|       |  // Skip trailing spaces and tabs.
 6533|  1.61k|  while (beg < end && is_space_or_tab(end[-1])) {
  ------------------
  |  Branch (6533:10): [True: 1.56k, False: 47]
  |  Branch (6533:23): [True: 368, False: 1.19k]
  ------------------
 6534|    368|    end--;
 6535|    368|  }
 6536|       |
 6537|  1.24k|  auto p = beg;
 6538|  95.8k|  while (p < end && *p != ':') {
  ------------------
  |  Branch (6538:10): [True: 95.7k, False: 83]
  |  Branch (6538:21): [True: 94.6k, False: 1.16k]
  ------------------
 6539|  94.6k|    p++;
 6540|  94.6k|  }
 6541|       |
 6542|  1.24k|  auto name = std::string(beg, p);
 6543|  1.24k|  if (!detail::fields::is_field_name(name)) { return false; }
  ------------------
  |  Branch (6543:7): [True: 82, False: 1.16k]
  ------------------
 6544|       |
 6545|  1.16k|  if (p == end) { return false; }
  ------------------
  |  Branch (6545:7): [True: 13, False: 1.15k]
  ------------------
 6546|       |
 6547|  1.15k|  auto key_end = p;
 6548|       |
 6549|  1.15k|  if (*p++ != ':') { return false; }
  ------------------
  |  Branch (6549:7): [True: 0, False: 1.15k]
  ------------------
 6550|       |
 6551|  1.55k|  while (p < end && is_space_or_tab(*p)) {
  ------------------
  |  Branch (6551:10): [True: 824, False: 726]
  |  Branch (6551:21): [True: 399, False: 425]
  ------------------
 6552|    399|    p++;
 6553|    399|  }
 6554|       |
 6555|  1.15k|  if (p <= end) {
  ------------------
  |  Branch (6555:7): [True: 1.15k, False: 0]
  ------------------
 6556|  1.15k|    auto key_len = key_end - beg;
 6557|  1.15k|    if (!key_len) { return false; }
  ------------------
  |  Branch (6557:9): [True: 0, False: 1.15k]
  ------------------
 6558|       |
 6559|  1.15k|    auto key = std::string(beg, key_end);
 6560|  1.15k|    auto val = std::string(p, end);
 6561|       |
 6562|  1.15k|    if (!detail::fields::is_field_value(val)) { return false; }
  ------------------
  |  Branch (6562:9): [True: 18, False: 1.13k]
  ------------------
 6563|       |
 6564|       |    // RFC 9110 §5.5: header field values are opaque octets and MUST NOT be
 6565|       |    // percent-decoded by the recipient. Applications that need to interpret a
 6566|       |    // value as a URI component should call httplib::decode_uri_component()
 6567|       |    // (or decode_path_component()) explicitly.
 6568|  1.13k|    fn(key, val);
 6569|       |
 6570|  1.13k|    return true;
 6571|  1.15k|  }
 6572|       |
 6573|      0|  return false;
 6574|  1.15k|}
_ZZN7httplib6detail14parse_trailersERNS0_18stream_line_readerERNS0_26insertion_ordered_multimapINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEENS0_11case_ignore8equal_toEEERKSD_ENKUlRKSA_SI_E_clESI_SI_:
 6654|  1.13k|                      [&](const std::string &key, const std::string &val) {
 6655|  1.13k|                        if (declared_trailers.find(key) !=
  ------------------
  |  Branch (6655:29): [True: 0, False: 1.13k]
  ------------------
 6656|  1.13k|                            declared_trailers.end()) {
 6657|      0|                          dest.emplace(key, val);
 6658|      0|                        }
 6659|  1.13k|                      })) {
_ZN7httplib6detail27read_content_without_lengthERNS_6StreamEmNSt3__18functionIFbPKcmmmEEE:
 9452|    520|                            ContentReceiverWithProgress out) {
 9453|    520|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 9454|    520|  size_t r = 0;
 9455|  1.72k|  for (;;) {
 9456|  1.72k|    auto n = strm.read(buf, CPPHTTPLIB_RECV_BUFSIZ);
  ------------------
  |  |  199|  1.72k|#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
  ------------------
 9457|  1.72k|    if (n == 0) { return ReadContentResult::Success; }
  ------------------
  |  Branch (9457:9): [True: 491, False: 1.23k]
  ------------------
 9458|  1.23k|    if (n < 0) { return ReadContentResult::Error; }
  ------------------
  |  Branch (9458:9): [True: 0, False: 1.23k]
  ------------------
 9459|       |
 9460|       |    // Check if adding this data would exceed the payload limit
 9461|  1.23k|    if (payload_max_length > 0 &&
  ------------------
  |  Branch (9461:9): [True: 1.23k, False: 0]
  ------------------
 9462|  1.23k|        (r > payload_max_length ||
  ------------------
  |  Branch (9462:10): [True: 0, False: 1.23k]
  ------------------
 9463|  1.23k|         payload_max_length - r < static_cast<size_t>(n))) {
  ------------------
  |  Branch (9463:10): [True: 0, False: 1.23k]
  ------------------
 9464|      0|      return ReadContentResult::PayloadTooLarge;
 9465|      0|    }
 9466|       |
 9467|  1.23k|    if (!out(buf, static_cast<size_t>(n), r, 0)) {
  ------------------
  |  Branch (9467:9): [True: 29, False: 1.20k]
  ------------------
 9468|     29|      return ReadContentResult::Error;
 9469|     29|    }
 9470|  1.20k|    r += static_cast<size_t>(n);
 9471|  1.20k|  }
 9472|       |
 9473|      0|  return ReadContentResult::Success;
 9474|    520|}
_ZN7httplib6detail24read_content_with_lengthERNS_6StreamEmNSt3__18functionIFbmmEEENS4_IFbPKcmmmEEEm:
 9412|    409|    size_t payload_max_length = (std::numeric_limits<size_t>::max)()) {
 9413|    409|  char buf[CPPHTTPLIB_RECV_BUFSIZ];
 9414|       |
 9415|    409|  detail::BodyReader br;
 9416|    409|  br.stream = &strm;
 9417|    409|  br.has_content_length = true;
 9418|    409|  br.content_length = len;
 9419|    409|  br.payload_max_length = payload_max_length;
 9420|    409|  br.chunked = false;
 9421|    409|  br.bytes_read = 0;
 9422|    409|  br.last_error = Error::Success;
 9423|       |
 9424|    409|  size_t r = 0;
 9425|  1.07k|  while (r < len) {
  ------------------
  |  Branch (9425:10): [True: 1.06k, False: 3]
  ------------------
 9426|  1.06k|    auto read_len = static_cast<size_t>(len - r);
 9427|  1.06k|    auto to_read = (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ);
  ------------------
  |  |  199|  1.06k|#define CPPHTTPLIB_RECV_BUFSIZ size_t(16384u)
  ------------------
 9428|  1.06k|    auto n = detail::read_body_content(&strm, br, buf, to_read);
 9429|  1.06k|    if (n <= 0) {
  ------------------
  |  Branch (9429:9): [True: 405, False: 664]
  ------------------
 9430|       |      // Check if it was a payload size error
 9431|    405|      if (br.last_error == Error::ExceedMaxPayloadSize) {
  ------------------
  |  Branch (9431:11): [True: 0, False: 405]
  ------------------
 9432|      0|        return ReadContentResult::PayloadTooLarge;
 9433|      0|      }
 9434|    405|      return ReadContentResult::Error;
 9435|    405|    }
 9436|       |
 9437|    664|    if (!out(buf, static_cast<size_t>(n), r, len)) {
  ------------------
  |  Branch (9437:9): [True: 1, False: 663]
  ------------------
 9438|      1|      return ReadContentResult::Error;
 9439|      1|    }
 9440|    663|    r += static_cast<size_t>(n);
 9441|       |
 9442|    663|    if (progress) {
  ------------------
  |  Branch (9442:9): [True: 663, False: 0]
  ------------------
 9443|    663|      if (!progress(r, len)) { return ReadContentResult::Error; }
  ------------------
  |  Branch (9443:11): [True: 0, False: 663]
  ------------------
 9444|    663|    }
 9445|    663|  }
 9446|       |
 9447|      3|  return ReadContentResult::Success;
 9448|    409|}
_ZN7httplib6detail17read_body_contentEPNS_6StreamERNS0_10BodyReaderEPcm:
 2797|  1.06k|                                 size_t len) {
 2798|  1.06k|  (void)stream;
 2799|  1.06k|  return br.read(buf, len);
 2800|  1.06k|}
_ZN7httplib6detail10BodyReader4readEPcm:
13271|  1.06k|inline ssize_t detail::BodyReader::read(char *buf, size_t len) {
13272|  1.06k|  if (!stream) {
  ------------------
  |  Branch (13272:7): [True: 0, False: 1.06k]
  ------------------
13273|      0|    last_error = Error::Connection;
13274|      0|    return -1;
13275|      0|  }
13276|  1.06k|  if (eof) { return 0; }
  ------------------
  |  Branch (13276:7): [True: 0, False: 1.06k]
  ------------------
13277|       |
13278|  1.06k|  if (!chunked) {
  ------------------
  |  Branch (13278:7): [True: 1.06k, False: 0]
  ------------------
13279|       |    // Content-Length based reading
13280|  1.06k|    if (has_content_length && bytes_read >= content_length) {
  ------------------
  |  Branch (13280:9): [True: 1.06k, False: 0]
  |  Branch (13280:31): [True: 0, False: 1.06k]
  ------------------
13281|      0|      eof = true;
13282|      0|      return 0;
13283|      0|    }
13284|       |
13285|  1.06k|    auto to_read = len;
13286|  1.06k|    if (has_content_length) {
  ------------------
  |  Branch (13286:9): [True: 1.06k, False: 0]
  ------------------
13287|  1.06k|      auto remaining = content_length - bytes_read;
13288|  1.06k|      to_read = (std::min)(len, remaining);
13289|  1.06k|    }
13290|  1.06k|    auto n = stream->read(buf, to_read);
13291|       |
13292|       |    // Without Content-Length the body ends when the connection closes
13293|       |    // (RFC 9112 §6.3); with one, an EOF here came too early
13294|  1.06k|    if (n < 0 || (n == 0 && has_content_length)) {
  ------------------
  |  Branch (13294:9): [True: 0, False: 1.06k]
  |  Branch (13294:19): [True: 405, False: 664]
  |  Branch (13294:29): [True: 405, False: 0]
  ------------------
13295|    405|      last_error = stream->get_error();
13296|    405|      if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (13296:11): [True: 405, False: 0]
  ------------------
13297|    405|    }
13298|  1.06k|    if (n <= 0) {
  ------------------
  |  Branch (13298:9): [True: 405, False: 664]
  ------------------
13299|    405|      eof = true;
13300|    405|      return n;
13301|    405|    }
13302|       |
13303|    664|    bytes_read += static_cast<size_t>(n);
13304|    664|    if (has_content_length && bytes_read >= content_length) { eof = true; }
  ------------------
  |  Branch (13304:9): [True: 664, False: 0]
  |  Branch (13304:31): [True: 3, False: 661]
  ------------------
13305|    664|    if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (13305:9): [True: 664, False: 0]
  |  Branch (13305:35): [True: 0, False: 664]
  ------------------
13306|      0|      last_error = Error::ExceedMaxPayloadSize;
13307|      0|      eof = true;
13308|      0|      return -1;
13309|      0|    }
13310|    664|    return n;
13311|    664|  }
13312|       |
13313|       |  // Chunked transfer encoding: delegate to shared decoder instance.
13314|      0|  if (!chunked_decoder) { chunked_decoder.reset(new ChunkedDecoder(*stream)); }
  ------------------
  |  Branch (13314:7): [True: 0, False: 0]
  ------------------
13315|       |
13316|      0|  size_t chunk_offset = 0;
13317|      0|  size_t chunk_total = 0;
13318|      0|  auto n = chunked_decoder->read_payload(buf, len, chunk_offset, chunk_total);
13319|      0|  if (n < 0) {
  ------------------
  |  Branch (13319:7): [True: 0, False: 0]
  ------------------
13320|      0|    last_error = stream->get_error();
13321|      0|    if (last_error == Error::Success) { last_error = Error::Read; }
  ------------------
  |  Branch (13321:9): [True: 0, False: 0]
  ------------------
13322|      0|    eof = true;
13323|      0|    return n;
13324|      0|  }
13325|       |
13326|      0|  if (n == 0) {
  ------------------
  |  Branch (13326:7): [True: 0, False: 0]
  ------------------
13327|       |    // Final chunk observed. Leave trailer parsing to the caller (StreamHandle).
13328|      0|    eof = true;
13329|      0|    return 0;
13330|      0|  }
13331|       |
13332|      0|  bytes_read += static_cast<size_t>(n);
13333|      0|  if (payload_max_length > 0 && bytes_read > payload_max_length) {
  ------------------
  |  Branch (13333:7): [True: 0, False: 0]
  |  Branch (13333:33): [True: 0, False: 0]
  ------------------
13334|      0|    last_error = Error::ExceedMaxPayloadSize;
13335|      0|    eof = true;
13336|      0|    return -1;
13337|      0|  }
13338|      0|  return n;
13339|      0|}
_ZNK7httplib6Stream9get_errorEv:
 2092|    405|  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:
 9611|  3.60k|                                        size_t len) {
 9612|  3.60k|    return receiver(buf, n, off, len);
 9613|  3.60k|  };
_ZZN7httplib10ClientImpl15process_requestERNS_6StreamERNS_7RequestERNS_8ResponseEbRNS_5ErrorEENKUlmmE_clEmm:
18431|    663|    auto progress = [&](size_t current, size_t total) {
18432|    663|      if (!req.download_progress || redirect) { return true; }
  ------------------
  |  Branch (18432:11): [True: 663, False: 0]
  |  Branch (18432:37): [True: 0, False: 0]
  ------------------
18433|      0|      auto ret = req.download_progress(current, total);
18434|      0|      if (!ret) { error = Error::Canceled; }
  ------------------
  |  Branch (18434:11): [True: 0, False: 0]
  ------------------
18435|      0|      return ret;
18436|    663|    };
_ZNK7httplib10ClientImpl10output_logERKNS_7RequestERKNS_8ResponseE:
18267|    525|                                   const Response &res) const {
18268|    525|  if (logger_) {
  ------------------
  |  Branch (18268:7): [True: 0, False: 525]
  ------------------
18269|      0|    std::lock_guard<std::mutex> guard(logger_mutex_);
18270|      0|    logger_(req, res);
18271|      0|  }
18272|    525|}
_ZN7httplib8ResponseD2Ev:
 1974|  3.31k|  ~Response() {
 1975|  3.31k|    if (content_provider_resource_releaser_) {
  ------------------
  |  Branch (1975:9): [True: 0, False: 3.31k]
  ------------------
 1976|      0|      content_provider_resource_releaser_(content_provider_success_);
 1977|      0|    }
 1978|  3.31k|  }
_ZNK7httplib6detail17gzip_decompressor8is_validEv:
 8880|    156|inline bool gzip_decompressor::is_valid() const { return is_valid_; }
_ZN7httplib6detail17gzip_decompressor10decompressEPKcmNSt3__18functionIFbS3_mEEE:
 8883|  2.83k|                                          Callback callback) {
 8884|  2.83k|  assert(is_valid_);
  ------------------
  |  Branch (8884:3): [True: 2.83k, False: 0]
  ------------------
 8885|       |
 8886|  2.83k|  auto ret = Z_OK;
 8887|       |
 8888|  2.83k|  do {
 8889|  2.83k|    constexpr size_t max_avail_in =
 8890|  2.83k|        (std::numeric_limits<decltype(strm_.avail_in)>::max)();
 8891|       |
 8892|  2.83k|    strm_.avail_in = static_cast<decltype(strm_.avail_in)>(
 8893|  2.83k|        (std::min)(data_length, max_avail_in));
 8894|  2.83k|    strm_.next_in = const_cast<Bytef *>(reinterpret_cast<const Bytef *>(data));
 8895|       |
 8896|  2.83k|    data_length -= strm_.avail_in;
 8897|  2.83k|    data += strm_.avail_in;
 8898|       |
 8899|  2.83k|    std::array<char, CPPHTTPLIB_COMPRESSION_BUFSIZ> buff{};
 8900|   118k|    while (strm_.avail_in > 0 && ret == Z_OK) {
  ------------------
  |  Branch (8900:12): [True: 115k, False: 2.46k]
  |  Branch (8900:34): [True: 115k, False: 338]
  ------------------
 8901|   115k|      strm_.avail_out = static_cast<uInt>(buff.size());
 8902|   115k|      strm_.next_out = reinterpret_cast<Bytef *>(buff.data());
 8903|       |
 8904|   115k|      ret = inflate(&strm_, Z_NO_FLUSH);
 8905|       |
 8906|   115k|      assert(ret != Z_STREAM_ERROR);
  ------------------
  |  Branch (8906:7): [True: 115k, False: 0]
  ------------------
 8907|   115k|      switch (ret) {
  ------------------
  |  Branch (8907:15): [True: 18, False: 115k]
  ------------------
 8908|      1|      case Z_NEED_DICT:
  ------------------
  |  Branch (8908:7): [True: 1, False: 115k]
  ------------------
 8909|     18|      case Z_DATA_ERROR:
  ------------------
  |  Branch (8909:7): [True: 17, False: 115k]
  ------------------
 8910|     18|      case Z_MEM_ERROR: inflateEnd(&strm_); return false;
  ------------------
  |  Branch (8910:7): [True: 0, False: 115k]
  ------------------
 8911|   115k|      }
 8912|       |
 8913|   115k|      if (!callback(buff.data(), buff.size() - strm_.avail_out)) {
  ------------------
  |  Branch (8913:11): [True: 14, False: 115k]
  ------------------
 8914|     14|        return false;
 8915|     14|      }
 8916|   115k|    }
 8917|       |
 8918|  2.80k|    if (ret != Z_OK && ret != Z_STREAM_END) { return false; }
  ------------------
  |  Branch (8918:9): [True: 340, False: 2.46k]
  |  Branch (8918:24): [True: 0, False: 340]
  ------------------
 8919|       |
 8920|  2.80k|  } while (data_length > 0);
  ------------------
  |  Branch (8920:12): [True: 0, False: 2.80k]
  ------------------
 8921|       |
 8922|  2.80k|  return true;
 8923|  2.83k|}
_ZN7httplib6detail12BufferStreamD2Ev:
 4111|  3.31k|  ~BufferStream() override = default;
_ZN7httplib6detail12BufferStream5writeEPKcm:
13707|  22.1k|inline ssize_t BufferStream::write(const char *ptr, size_t size) {
13708|  22.1k|  buffer.append(ptr, size);
13709|  22.1k|  return static_cast<ssize_t>(size);
13710|  22.1k|}
_ZNK7httplib6Stream13buffered_dataERm:
 2081|  4.24M|  virtual const char *buffered_data(size_t &size) const {
 2082|  4.24M|    size = 0;
 2083|  4.24M|    return nullptr;
 2084|  4.24M|  }
_ZNK7httplib10ClientImpl6is_sslEv:
18549|  3.31k|inline bool ClientImpl::is_ssl() const { return false; }

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

