From b8abe41a5081728f9f4c824ef810902a11ab7ffd Mon Sep 17 00:00:00 2001 From: "Alessandro de Oliveira Faria (A.K.A.CABELO)" Date: Wed, 11 Nov 2026 09:07:30 -0300 Subject: [PATCH] vendor: update cpp-httplib to 0.66.0 (#32049) --- scripts/sync_vendor.py | 2 +- vendor/cpp-httplib/httplib.cpp | 42 +++++++++++++++++++++++++++++----- vendor/cpp-httplib/httplib.h | 4 ++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/scripts/sync_vendor.py b/scripts/sync_vendor.py index 0a5271dc1..fed4914ff 100755 --- a/scripts/sync_vendor.py +++ b/scripts/sync_vendor.py @@ -5,7 +5,7 @@ import os import sys import subprocess -HTTPLIB_VERSION = "refs/tags/v0.65.0" +HTTPLIB_VERSION = "refs/tags/v0.66.0" # used by examples/gguf-hash, these repos have no release tag, so we pin a commit XXHASH_COMMIT = "9f465f1ea932d6ad9a26cd77496311ffa544cd68" diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cpp index e67157ad3..1d883acdb 100644 --- a/vendor/cpp-httplib/httplib.cpp +++ b/vendor/cpp-httplib/httplib.cpp @@ -7703,7 +7703,16 @@ bool ThreadPool::enqueue(std::function fn) { if (jobs_.size() > idle_thread_count_ && threads_.size() + dynamic_threads_.size() < max_thread_count_) { cleanup_finished_threads(); - dynamic_threads_.emplace_back(std::thread([this]() { worker(true); })); +#ifndef CPPHTTPLIB_NO_EXCEPTIONS + try { +#endif + dynamic_threads_.emplace_back(std::thread([this]() { worker(true); })); +#ifndef CPPHTTPLIB_NO_EXCEPTIONS + } catch (const std::system_error &) { + // No thread budget left: keep the job queued for an existing worker + // instead of letting the exception escape the accept loop. + } +#endif } } @@ -8158,14 +8167,22 @@ make_host_and_port_string_always_port(const std::string &host, int port) { return prepare_host_string(host) + ":" + std::to_string(port); } +// Where a client connects for `host`, as one string: the mapped address or +// name, or `host` itself. +std::string +addr_map_target(const std::map &addr_map, + const std::string &host) { + std::string connect_host; + std::string ip; + apply_addr_map(addr_map, host, connect_host, ip); + return ip.empty() ? connect_host : ip; +} + // Request target of a CONNECT for `host`, with `addr_map` applied. std::string make_connect_request_target(const std::map &addr_map, const std::string &host, int port) { - std::string connect_host; - std::string ip; - apply_addr_map(addr_map, host, connect_host, ip); - return make_host_and_port_string_always_port(ip.empty() ? connect_host : ip, + return make_host_and_port_string_always_port(addr_map_target(addr_map, host), port); } @@ -11553,8 +11570,13 @@ bool ClientImpl::redirect(Request &req, Response &res, Error &error) { auto path = std::move(next_path) + next_query; + // A Unix socket client sends "Host: localhost", so a Location naming + // localhost names this client too. + auto is_same_host = next_host == host_ || + (address_family_ == AF_UNIX && next_host == "localhost"); + // Same host redirect - use current client - if (next_scheme == scheme && next_host == host_ && next_port == port_) { + if (next_scheme == scheme && is_same_host && next_port == port_) { return detail::redirect(*this, req, res, path, location, error); } @@ -11705,6 +11727,14 @@ void ClientImpl::setup_redirect_client(ClientType &client) { // Copy network and socket settings client.addr_map_ = addr_map_; client.tunnel_addr_map_ = tunnel_addr_map_; + + // A Unix socket client reaches every host through its own socket, as curl's + // --unix-socket does, unless the caller mapped that host elsewhere. The + // Location's host is never taken as a socket path. + if (address_family_ == AF_UNIX) { + auto &target = client.addr_map_[client.host()]; + if (target.empty()) { target = detail::addr_map_target(addr_map_, host_); } + } client.set_address_family(address_family_); client.set_tcp_nodelay(tcp_nodelay_); client.set_ipv6_v6only(ipv6_v6only_); diff --git a/vendor/cpp-httplib/httplib.h b/vendor/cpp-httplib/httplib.h index 9a7acd71d..489d1ef01 100644 --- a/vendor/cpp-httplib/httplib.h +++ b/vendor/cpp-httplib/httplib.h @@ -8,8 +8,8 @@ #ifndef CPPHTTPLIB_HTTPLIB_H #define CPPHTTPLIB_HTTPLIB_H -#define CPPHTTPLIB_VERSION "0.65.0" -#define CPPHTTPLIB_VERSION_NUM "0x004100" +#define CPPHTTPLIB_VERSION "0.66.0" +#define CPPHTTPLIB_VERSION_NUM "0x004200" #ifdef _WIN32 #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00