Skip to content

Commit 557fe2d

Browse files
authored
vendor : update cpp-httplib to 0.37.1 (ggml-org#20390)
1 parent 0e81041 commit 557fe2d

3 files changed

Lines changed: 16 additions & 29 deletions

File tree

scripts/sync_vendor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
import subprocess
77

8-
HTTPLIB_VERSION = "refs/tags/v0.37.0"
8+
HTTPLIB_VERSION = "refs/tags/v0.37.1"
99

1010
vendor = {
1111
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",

vendor/cpp-httplib/httplib.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4424,7 +4424,8 @@ get_range_offset_and_length(Range r, size_t content_length) {
44244424
assert(r.first <= r.second &&
44254425
r.second < static_cast<ssize_t>(content_length));
44264426
(void)(content_length);
4427-
return std::make_pair(r.first, static_cast<size_t>(r.second - r.first) + 1);
4427+
return std::make_pair(static_cast<size_t>(r.first),
4428+
static_cast<size_t>(r.second - r.first) + 1);
44284429
}
44294430

44304431
std::string make_content_range_header_field(
@@ -8616,11 +8617,17 @@ ClientImpl::open_stream(const std::string &method, const std::string &path,
86168617
handle.body_reader_.stream = handle.stream_;
86178618
handle.body_reader_.payload_max_length = payload_max_length_;
86188619

8619-
auto content_length_str = handle.response->get_header_value("Content-Length");
8620-
if (!content_length_str.empty()) {
8620+
if (handle.response->has_header("Content-Length")) {
8621+
bool is_invalid = false;
8622+
auto content_length = detail::get_header_value_u64(
8623+
handle.response->headers, "Content-Length", 0, 0, is_invalid);
8624+
if (is_invalid) {
8625+
handle.error = Error::Read;
8626+
handle.response.reset();
8627+
return handle;
8628+
}
86218629
handle.body_reader_.has_content_length = true;
8622-
handle.body_reader_.content_length =
8623-
static_cast<size_t>(std::stoull(content_length_str));
8630+
handle.body_reader_.content_length = content_length;
86248631
}
86258632

86268633
auto transfer_encoding =

vendor/cpp-httplib/httplib.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,8 @@
88
#ifndef CPPHTTPLIB_HTTPLIB_H
99
#define CPPHTTPLIB_HTTPLIB_H
1010

11-
#define CPPHTTPLIB_VERSION "0.37.0"
12-
#define CPPHTTPLIB_VERSION_NUM "0x002500"
13-
14-
/*
15-
* Platform compatibility check
16-
*/
17-
18-
#if defined(_WIN32) && !defined(_WIN64)
19-
#if defined(_MSC_VER)
20-
#pragma message( \
21-
"cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler.")
22-
#else
23-
#warning \
24-
"cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler."
25-
#endif
26-
#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ < 8
27-
#warning \
28-
"cpp-httplib doesn't support 32-bit platforms. Please use a 64-bit compiler."
29-
#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ < 8
30-
#warning \
31-
"cpp-httplib doesn't support platforms where size_t is less than 64 bits."
32-
#endif
11+
#define CPPHTTPLIB_VERSION "0.37.1"
12+
#define CPPHTTPLIB_VERSION_NUM "0x002501"
3313

3414
#ifdef _WIN32
3515
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
@@ -2797,7 +2777,7 @@ inline size_t get_header_value_u64(const Headers &headers,
27972777
std::advance(it, static_cast<ssize_t>(id));
27982778
if (it != rng.second) {
27992779
if (is_numeric(it->second)) {
2800-
return std::strtoull(it->second.data(), nullptr, 10);
2780+
return static_cast<size_t>(std::strtoull(it->second.data(), nullptr, 10));
28012781
} else {
28022782
is_invalid_value = true;
28032783
}

0 commit comments

Comments
 (0)