LLM inference in C/C++
C++ ggml
vendor : update cpp-httplib to 0.46.1 (#23980)
Adrien Gallouët335abed17dec
diff --git a/scripts/sync_vendor.py b/scripts/sync_vendor.pyindex fec05d97db..8306cf93ec 100755--- a/scripts/sync_vendor.py+++ b/scripts/sync_vendor.py@@ -5,7 +5,7 @@ import osimport sysimport subprocess-HTTPLIB_VERSION = "refs/tags/v0.46.0"+HTTPLIB_VERSION = "refs/tags/v0.46.1"vendor = {"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cppindex f3555f2d41..b9d05d9296 100644--- a/vendor/cpp-httplib/httplib.cpp+++ b/vendor/cpp-httplib/httplib.cpp@@ -1832,7 +1832,7 @@ int getaddrinfo_with_timeout(const char *node, const char *service,#ifdef _WIN32// Windows-specific implementation using GetAddrInfoEx with overlapped I/O- OVERLAPPED overlapped = {0};+ OVERLAPPED overlapped = {};HANDLE event = CreateEventW(nullptr, TRUE, FALSE, nullptr);if (!event) { return EAI_FAIL; }@@ -1841,7 +1841,7 @@ int getaddrinfo_with_timeout(const char *node, const char *service,PADDRINFOEXW result_addrinfo = nullptr;HANDLE cancel_handle = nullptr;- ADDRINFOEXW hints_ex = {0};+ ADDRINFOEXW hints_ex = {};if (hints) {hints_ex.ai_flags = hints->ai_flags;hints_ex.ai_family = hints->ai_family;@@ -9912,13 +9912,28 @@ bool ClientImpl::process_request(Stream &strm, Request &req,}#endif- // Handle Expect: 100-continue with timeout- if (expect_100_continue && CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND > 0) {- time_t sec = CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND / 1000;- time_t usec = (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND % 1000) * 1000;- auto ret = detail::select_read(strm.socket(), sec, usec);- if (ret <= 0) {- // Timeout or error: send body anyway (server didn't respond in time)+ // Handle Expect: 100-continue.+ //+ // Wait for an interim/early response by attempting to read the status line+ // under a short timeout, instead of trusting raw socket readability. Over+ // TLS, post-handshake records (e.g. session tickets) make the socket+ // readable without any HTTP response being available; relying on+ // `select_read` there caused the body to be withheld forever and the+ // request to fail with `Read` (#2458). If no status line arrives within the+ // timeout, send the body anyway (matching curl's behavior).+ auto status_line_read = false;+ if (expect_100_continue && write_request_success) {+ if (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND > 0) {+ time_t sec = CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND / 1000;+ time_t usec = (CPPHTTPLIB_EXPECT_100_TIMEOUT_MSECOND % 1000) * 1000;+ strm.set_read_timeout(sec, usec);+ status_line_read = read_response_line(strm, req, res, false);+ strm.set_read_timeout(read_timeout_sec_, read_timeout_usec_);+ }++ if (!status_line_read) {+ // No interim response within the timeout: send the body and handle the+ // response as usual.if (!write_request_body(strm, req, error)) { return false; }expect_100_continue = false; // Switch to normal response handling}@@ -9926,7 +9941,8 @@ bool ClientImpl::process_request(Stream &strm, Request &req,// Receive response and headers// When using Expect: 100-continue, don't auto-skip `100 Continue` response- if (!read_response_line(strm, req, res, !expect_100_continue) ||+ if ((!status_line_read &&+ !read_response_line(strm, req, res, !expect_100_continue)) ||!detail::read_headers(strm, res.headers)) {if (write_request_success) { error = Error::Read; }output_error_log(error, &req);diff --git a/vendor/cpp-httplib/httplib.h b/vendor/cpp-httplib/httplib.hindex af856dd631..cbb549e712 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.46.0"-#define CPPHTTPLIB_VERSION_NUM "0x002e00"+#define CPPHTTPLIB_VERSION "0.46.1"+#define CPPHTTPLIB_VERSION_NUM "0x002e01"#ifdef _WIN32#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00