diff --git a/scripts/sync_vendor.py b/scripts/sync_vendor.py index a8bb6c4ffc..75d4a5ff61 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.37.0" +HTTPLIB_VERSION = "refs/tags/v0.37.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.cpp index c8f88d87df..71a5f00567 100644 --- a/vendor/cpp-httplib/httplib.cpp +++ b/vendor/cpp-httplib/httplib.cpp @@ -4424,7 +4424,8 @@ get_range_offset_and_length(Range r, size_t content_length) { assert(r.first <= r.second && r.second < static_cast(content_length)); (void)(content_length); - return std::make_pair(r.first, static_cast(r.second - r.first) + 1); + return std::make_pair(static_cast(r.first), + static_cast(r.second - r.first) + 1); } std::string make_content_range_header_field( @@ -8616,11 +8617,17 @@ ClientImpl::open_stream(const std::string &method, const std::string &path, handle.body_reader_.stream = handle.stream_; handle.body_reader_.payload_max_length = payload_max_length_; - auto content_length_str = handle.response->get_header_value("Content-Length"); - if (!content_length_str.empty()) { + if (handle.response->has_header("Content-Length")) { + bool is_invalid = false; + auto content_length = detail::get_header_value_u64( + handle.response->headers, "Content-Length", 0, 0, is_invalid); + if (is_invalid) { + handle.error = Error::Read; + handle.response.reset(); + return handle; + } handle.body_reader_.has_content_length = true; - handle.body_reader_.content_length = - static_cast(std::stoull(content_length_str)); + handle.body_reader_.content_length = content_length; } auto transfer_encoding = diff --git a/vendor/cpp-httplib/httplib.h b/vendor/cpp-httplib/httplib.h index ac1908f421..e01b3550ba 100644 --- a/vendor/cpp-httplib/httplib.h +++ b/vendor/cpp-httplib/httplib.h @@ -8,28 +8,8 @@ #ifndef CPPHTTPLIB_HTTPLIB_H #define CPPHTTPLIB_HTTPLIB_H -#define CPPHTTPLIB_VERSION "0.37.0" -#define CPPHTTPLIB_VERSION_NUM "0x002500" - -/* - * Platform compatibility check - */ - -#if defined(_WIN32) && !defined(_WIN64) -#if defined(_MSC_VER) -#pragma message( \ - "cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler.") -#else -#warning \ - "cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler." -#endif -#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ < 8 -#warning \ - "cpp-httplib doesn't support 32-bit platforms. Please use a 64-bit compiler." -#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ < 8 -#warning \ - "cpp-httplib doesn't support platforms where size_t is less than 64 bits." -#endif +#define CPPHTTPLIB_VERSION "0.37.1" +#define CPPHTTPLIB_VERSION_NUM "0x002501" #ifdef _WIN32 #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00 @@ -2797,7 +2777,7 @@ inline size_t get_header_value_u64(const Headers &headers, std::advance(it, static_cast(id)); if (it != rng.second) { if (is_numeric(it->second)) { - return std::strtoull(it->second.data(), nullptr, 10); + return static_cast(std::strtoull(it->second.data(), nullptr, 10)); } else { is_invalid_value = true; }