Commit 5a18afaf7 for llama.cpp

commit 5a18afaf7cf9ae5176fe62b9bd0241e841b26fc7
Author: Alessandro de Oliveira Faria (A.K.A.CABELO) <cabelo@opensuse.org>
Date:   Sun Nov 29 15:18:41 2026 -0300

    vendor : update cpp-httplib-0.69.0 (#33310)

    [no ci]

diff --git a/scripts/sync_vendor.py b/scripts/sync_vendor.py
index 6344f2ad2..1e55744b5 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.68.0"
+HTTPLIB_VERSION = "refs/tags/v0.69.0"
 JSON_VERSION    = "v3.12.0"

 # stb has no release tag, so we pin a commit (stb_image v2.32)
diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cpp
index 74df8eec1..50de2bacc 100644
--- a/vendor/cpp-httplib/httplib.cpp
+++ b/vendor/cpp-httplib/httplib.cpp
@@ -5986,75 +5986,6 @@ std::string escape_quoted_pairs(const std::string &s) {
   return out;
 }

-// RFC 9110 Section 11.6.1 defines a challenge list as
-//   WWW-Authenticate = #challenge
-//   challenge        = auth-scheme [ 1*SP ( token68 / [ #auth-param ] ) ]
-//   auth-param       = token BWS "=" BWS ( token / quoted-string )
-// so a server may offer several schemes, each with its own comma-separated
-// auth-param list, in either order and either as separate field lines or
-// packed into one. Splitting on every comma would break apart a challenge's
-// own param list; splitting only on the first space would miss a Digest
-// challenge that isn't first. Split on commas that aren't inside a
-// quoted-string instead (split_unquoted), then track which scheme each
-// resulting segment belongs to: a segment whose text before "=" contains
-// whitespace (or that has no "=" at all) starts a new challenge named by its
-// leading token.
-bool parse_www_authenticate(const Response &res,
-                                   std::map<std::string, std::string> &auth,
-                                   bool is_proxy) {
-  auto auth_key = is_proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
-  auto combined = get_combined_header_value(res.headers, auth_key);
-  if (combined.empty()) { return false; }
-
-  auto found_digest = false;
-  auto in_digest_challenge = false;
-  split_unquoted(
-      combined.data(), combined.data() + combined.size(), ',',
-      [&](const char *b, const char *e) {
-        std::string segment(b, e);
-        auto eq_pos = segment.find('=');
-        // BWS is allowed on both sides of "=", so the text naming the key (or,
-        // for the first segment of a challenge, "<scheme> <key>") must be
-        // trimmed before its boundaries are inspected.
-        auto key_part = trim_copy(
-            eq_pos == std::string::npos ? segment : segment.substr(0, eq_pos));
-        auto space_pos = key_part.find_last_of(" \t");
-        if (space_pos != std::string::npos || eq_pos == std::string::npos) {
-          // "<scheme>[ <key>]" starts a new challenge.
-          auto scheme_end =
-              space_pos == std::string::npos ? key_part.size() : space_pos;
-          // RFC 7616 Section 3.7: a server may offer more than one Digest
-          // challenge (e.g. SHA-256 and MD5); keep only the first so a nonce
-          // from one challenge is never paired with another's algorithm.
-          in_digest_challenge =
-              !found_digest &&
-              case_ignore::equal(key_part.substr(0, scheme_end), "Digest");
-          if (in_digest_challenge) { found_digest = true; }
-          if (space_pos == std::string::npos) {
-            // Bare scheme (or a token68), no auth-param on this segment.
-            return;
-          }
-          key_part = key_part.substr(space_pos + 1);
-        }
-
-        if (!in_digest_challenge) { return; }
-
-        auto val = trim_copy(segment.substr(eq_pos + 1));
-        auto unquoted = trim_double_quotes_copy(val);
-        if (unquoted.size() != val.size()) {
-          unquoted = unescape_quoted_pairs(unquoted);
-        }
-        auth[std::move(key_part)] = std::move(unquoted);
-      });
-
-  // RFC 7616 Section 3.3 requires realm and nonce on every Digest challenge;
-  // make_digest_authentication_header() dereferences both unconditionally, so
-  // a challenge missing either can't produce a usable Authorization header.
-  // Treat it the same as no Digest challenge at all.
-  return found_digest && auth.find("realm") != auth.end() &&
-         auth.find("nonce") != auth.end();
-}
-
 class ContentProviderAdapter {
 public:
   explicit ContentProviderAdapter(
@@ -6523,6 +6454,121 @@ bool process_client_socket_ssl(
   return callback(strm);
 }

+using DigestHash = std::string (*)(const std::string &);
+
+// The Digest algorithms the client implements, matched case-insensitively;
+// nullptr for any other.
+DigestHash digest_hash(const std::string &algorithm) {
+  if (case_ignore::equal(algorithm, "MD5")) { return detail::MD5; }
+  if (case_ignore::equal(algorithm, "SHA-256")) { return detail::SHA_256; }
+  if (case_ignore::equal(algorithm, "SHA-512")) { return detail::SHA_512; }
+  return nullptr;
+}
+
+// Picks auth over auth-int from the qop options a server offers, as curl does:
+// auth-int hashes req.body, which is empty when a content provider streams the
+// body. Empty when it offers neither.
+std::string select_digest_qop(const std::string &options) {
+  std::string qop;
+  split(options.data(), options.data() + options.size(), ',',
+        [&](const char *b, const char *e) {
+          std::string option(b, e);
+          if (case_ignore::equal(option, "auth")) {
+            qop = "auth";
+          } else if (qop.empty() && case_ignore::equal(option, "auth-int")) {
+            qop = "auth-int";
+          }
+        });
+  return qop;
+}
+
+// RFC 9110 Section 11.6.1 defines a challenge list as
+//   WWW-Authenticate = #challenge
+//   challenge        = auth-scheme [ 1*SP ( token68 / [ #auth-param ] ) ]
+//   auth-param       = token BWS "=" BWS ( token / quoted-string )
+// so a server may offer several schemes, each with its own comma-separated
+// auth-param list, in either order and either as separate field lines or
+// packed into one. Splitting on every comma would break apart a challenge's
+// own param list; splitting only on the first space would miss a Digest
+// challenge that isn't first. Split on commas that aren't inside a
+// quoted-string instead (split_unquoted), then track which scheme each
+// resulting segment belongs to: a segment whose text before "=" contains
+// whitespace (or that has no "=" at all) starts a new challenge named by its
+// leading token.
+bool parse_www_authenticate(const Response &res,
+                                   std::map<std::string, std::string> &auth,
+                                   bool is_proxy) {
+  auto auth_key = is_proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
+  auto combined = get_combined_header_value(res.headers, auth_key);
+  if (combined.empty()) { return false; }
+
+  // RFC 7616 Section 3.7: a server may offer more than one Digest challenge
+  // (e.g. SHA-256 and MD5), and the client uses the first one it supports.
+  // A challenge whose algorithm the client doesn't implement is ignored
+  // (Section 3.3), as is one whose qop offers neither auth nor auth-int, and
+  // one without realm and nonce can't be answered. Params are collected per
+  // challenge, so a nonce from one is never paired with another's algorithm.
+  auto answerable = [](const std::map<std::string, std::string> &c) {
+    if (c.find("realm") == c.end() || c.find("nonce") == c.end()) {
+      return false;
+    }
+    auto algo_it = c.find("algorithm");
+    if (algo_it != c.end() && !digest_hash(algo_it->second)) { return false; }
+    auto qop_it = c.find("qop");
+    return qop_it == c.end() || !select_digest_qop(qop_it->second).empty();
+  };
+
+  auto found = false;
+  auto in_digest_challenge = false;
+  std::map<std::string, std::string> challenge;
+  auto take_challenge_if_answerable = [&] {
+    if (!found && in_digest_challenge && answerable(challenge)) {
+      auth = std::move(challenge);
+      found = true;
+    }
+    challenge.clear();
+  };
+
+  split_unquoted(
+      combined.data(), combined.data() + combined.size(), ',',
+      [&](const char *b, const char *e) {
+        std::string segment(b, e);
+        auto eq_pos = segment.find('=');
+        // BWS is allowed on both sides of "=", so the text naming the key (or,
+        // for the first segment of a challenge, "<scheme> <key>") must be
+        // trimmed before its boundaries are inspected.
+        auto key_part = trim_copy(
+            eq_pos == std::string::npos ? segment : segment.substr(0, eq_pos));
+        auto space_pos = key_part.find_first_of(" \t");
+        if (space_pos != std::string::npos || eq_pos == std::string::npos) {
+          // "<scheme>[ <key>]" starts a new challenge.
+          take_challenge_if_answerable();
+          auto scheme_end =
+              space_pos == std::string::npos ? key_part.size() : space_pos;
+          in_digest_challenge =
+              case_ignore::equal(key_part.substr(0, scheme_end), "Digest");
+          if (space_pos == std::string::npos) {
+            // Bare scheme (or a token68), no auth-param on this segment.
+            return;
+          }
+          key_part = trim_copy(key_part.substr(space_pos + 1));
+        }
+
+        if (!in_digest_challenge) { return; }
+
+        auto val = trim_copy(segment.substr(eq_pos + 1));
+        auto unquoted = trim_double_quotes_copy(val);
+        if (unquoted.size() != val.size()) {
+          unquoted = unescape_quoted_pairs(unquoted);
+        }
+        // auth-param names are case-insensitive (RFC 9110 Section 11.2)
+        challenge[case_ignore::to_lower(key_part)] = std::move(unquoted);
+      });
+  take_challenge_if_answerable();
+
+  return found;
+}
+
 // `uri` is req's request-target in origin form, as curl sends it, also when
 // the request line carries the absolute form for a proxy.
 std::pair<std::string, std::string> make_digest_authentication_header(
@@ -6537,33 +6583,21 @@ std::pair<std::string, std::string> make_digest_authentication_header(
     nc = ss.str();
   }

-  std::string qop;
-  if (auth.find("qop") != auth.end()) {
-    qop = auth.at("qop");
-    if (qop.find("auth-int") != std::string::npos) {
-      qop = "auth-int";
-    } else if (qop.find("auth") != std::string::npos) {
-      qop = "auth";
-    } else {
-      qop.clear();
-    }
-  }
+  // Without qop, the RFC 2069 form is used.
+  auto qop_it = auth.find("qop");
+  auto qop =
+      qop_it == auth.end() ? std::string() : select_digest_qop(qop_it->second);
+  assert(qop_it == auth.end() || !qop.empty());

-  std::string algo = "MD5";
-  if (auth.find("algorithm") != auth.end()) {
-    // algorithm is an unquoted token (RFC 7616 §3.4). A server value that is
-    // not a token would otherwise be emitted verbatim and could carry commas
-    // or quotes that inject further auth-params into the header below.
-    const auto &a = auth.at("algorithm");
-    if (fields::is_token(a)) { algo = a; }
-  }
+  // Sent back as the server wrote it (RFC 7616 Section 3.4).
+  // parse_www_authenticate() accepts only one digest_hash() knows.
+  auto algo_it = auth.find("algorithm");
+  auto algo = algo_it == auth.end() ? std::string("MD5") : algo_it->second;
+  auto H = digest_hash(algo);
+  assert(H);

   std::string response;
   {
-    auto H = algo == "SHA-256"   ? detail::SHA_256
-             : algo == "SHA-512" ? detail::SHA_512
-                                 : detail::MD5;
-
     auto A1 = username + ":" + auth.at("realm") + ":" + password;

     auto A2 = req.method + ":" + uri;
@@ -7058,15 +7092,16 @@ bool set_socket_opt(socket_t sock, int level, int optname, int optval) {
 }

 std::string get_bearer_token_auth(const Request &req) {
-  // The auth scheme is case-insensitive (RFC 9110 11.1), and a value shorter
-  // than the prefix carries no token.
+  // The auth scheme is case-insensitive (RFC 9110 11.1) and followed by 1*SP,
+  // and a value shorter than the prefix carries no token.
   constexpr const char bearer_prefix[] = "Bearer ";
   constexpr auto bearer_prefix_len = detail::str_len(bearer_prefix);
   auto value = req.get_header_value("Authorization");
   if (value.size() >= bearer_prefix_len &&
       detail::case_ignore::equal(value.substr(0, bearer_prefix_len),
                                  bearer_prefix)) {
-    return value.substr(bearer_prefix_len);
+    auto pos = value.find_first_not_of(' ', bearer_prefix_len);
+    if (pos != std::string::npos) { return value.substr(pos); }
   }
   return "";
 }
diff --git a/vendor/cpp-httplib/httplib.h b/vendor/cpp-httplib/httplib.h
index 6e0202731..5be7a2383 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.68.0"
-#define CPPHTTPLIB_VERSION_NUM "0x004400"
+#define CPPHTTPLIB_VERSION "0.69.0"
+#define CPPHTTPLIB_VERSION_NUM "0x004500"

 #ifdef _WIN32
 #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
@@ -565,6 +565,13 @@ using socket_t = int;
 #define CPPHTTPLIB_MBEDTLS_V3
 #endif

+// SSLServer (and SSLClients on several threads) use Mbed TLS concurrently.
+#if !defined(MBEDTLS_THREADING_C) &&                                           \
+    !defined(CPPHTTPLIB_MBEDTLS_SINGLE_THREADED)
+#error                                                                         \
+    "Mbed TLS must be built with MBEDTLS_THREADING_C. Define CPPHTTPLIB_MBEDTLS_SINGLE_THREADED if it is only ever used from one thread."
+#endif
+
 #endif // CPPHTTPLIB_MBEDTLS_SUPPORT

 #ifdef CPPHTTPLIB_WOLFSSL_SUPPORT