vendor : update cpp-httplib to 0.53.0 (#26821)

This commit is contained in:
Alessandro de Oliveira Faria (A.K.A.CABELO)
2026-08-10 09:57:45 +02:00
committed by GitHub
parent 157b81fe6d
commit e23e9440eb
3 changed files with 577 additions and 293 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import os
import sys
import subprocess
HTTPLIB_VERSION = "refs/tags/v0.52.0"
HTTPLIB_VERSION = "refs/tags/v0.53.0"
vendor = {
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
+478 -285
View File
File diff suppressed because it is too large Load Diff
+98 -7
View File
@@ -8,8 +8,8 @@
#ifndef CPPHTTPLIB_HTTPLIB_H
#define CPPHTTPLIB_HTTPLIB_H
#define CPPHTTPLIB_VERSION "0.52.0"
#define CPPHTTPLIB_VERSION_NUM "0x003400"
#define CPPHTTPLIB_VERSION "0.53.0"
#define CPPHTTPLIB_VERSION_NUM "0x003500"
#ifdef _WIN32
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
@@ -1805,6 +1805,7 @@ enum class Error {
HTTPParsing,
InvalidRangeHeader,
UnsupportedContentEncoding,
WebSocketHandshake,
// For internal use only
SSLPeerCouldBeClosed_,
@@ -3233,8 +3234,6 @@ private:
// Used to keep custom CA configuration exclusive with system CA loading.
bool ca_cert_store_set_ = false;
long verify_result_ = 0;
std::function<SSLVerifierResponse(tls::session_t)> session_verifier_;
#ifdef CPPHTTPLIB_WINDOWS_AUTOMATIC_ROOT_CERTIFICATES_UPDATE
@@ -4204,6 +4203,50 @@ enum class CloseStatus : uint16_t {
enum ReadResult : int { Fail = 0, Text = 1, Binary = 2 };
// Result of WebSocketClient::connect(). Truthy only when the WebSocket
// upgrade handshake fully succeeded. On failure error() identifies the
// failing layer; status()/headers() expose the server's upgrade response
// when one was received (status() is -1 otherwise).
class Result {
public:
Result() = default;
Result(Error err, int status, Headers &&headers)
: err_(err), status_(status), headers_(std::move(headers)) {}
explicit operator bool() const { return err_ == Error::Success; }
Error error() const { return err_; }
// Upgrade response info
int status() const { return status_; }
const Headers &headers() const { return headers_; }
std::string get_header_value(const std::string &key,
const char *def = "") const {
return detail::get_header_value(headers_, key, def, 0);
}
bool has_header(const std::string &key) const {
return headers_.find(key) != headers_.end();
}
#ifdef CPPHTTPLIB_SSL_ENABLED
Result(Error err, int status, Headers &&headers, int ssl_error,
uint64_t ssl_backend_error)
: err_(err), status_(status), headers_(std::move(headers)),
ssl_error_(ssl_error), ssl_backend_error_(ssl_backend_error) {}
int ssl_error() const { return ssl_error_; }
uint64_t ssl_backend_error() const { return ssl_backend_error_; }
#endif
private:
Error err_ = Error::Unknown; // a default-constructed Result is falsy
int status_ = -1;
Headers headers_;
#ifdef CPPHTTPLIB_SSL_ENABLED
int ssl_error_ = 0;
uint64_t ssl_backend_error_ = 0;
#endif
};
class WebSocket {
public:
WebSocket(const WebSocket &) = delete;
@@ -4270,7 +4313,7 @@ public:
bool is_valid() const;
bool connect();
Result connect();
ReadResult read(std::string &msg);
bool send(const std::string &data);
bool send(const char *data, size_t len);
@@ -4279,28 +4322,52 @@ public:
bool is_open() const;
const std::string &subprotocol() const;
void set_read_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
void set_read_timeout(const std::chrono::duration<Rep, Period> &duration);
void set_write_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
void set_write_timeout(const std::chrono::duration<Rep, Period> &duration);
void set_websocket_ping_interval(time_t sec);
void set_websocket_max_missed_pongs(int count);
void set_tcp_nodelay(bool on);
void set_address_family(int family);
void set_ipv6_v6only(bool on);
void set_socket_options(SocketOptions socket_options);
void set_connection_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
void
set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
void set_interface(const std::string &intf);
void set_hostname_addr_map(std::map<std::string, std::string> addr_map);
#ifdef CPPHTTPLIB_SSL_ENABLED
void set_ca_cert_path(const std::string &path);
struct PemMemory {
const char *cert_pem;
size_t cert_pem_len;
const char *key_pem;
size_t key_pem_len;
const char *private_key_password;
};
explicit WebSocketClient(const std::string &scheme_host_port_path,
const PemMemory &pem, const Headers &headers = {});
void set_ca_cert_path(const std::string &ca_cert_file_path,
const std::string &ca_cert_dir_path = std::string());
void set_ca_cert_store(tls::ca_store_t store);
void load_ca_cert_store(const char *ca_cert, std::size_t size);
void enable_server_certificate_verification(bool enabled);
void enable_server_hostname_verification(bool enabled);
void enable_system_ca(bool enabled);
#endif
private:
void shutdown_and_close();
bool create_stream(std::unique_ptr<Stream> &strm);
bool create_stream(std::unique_ptr<Stream> &strm, Error &error,
int &ssl_error, uint64_t &ssl_backend_error);
void prepare_default_headers(Request &req);
std::string host_;
@@ -4335,13 +4402,37 @@ private:
tls::ctx_t tls_ctx_ = nullptr;
tls::session_t tls_session_ = nullptr;
std::string ca_cert_file_path_;
std::string ca_cert_dir_path_;
bool custom_ca_loaded_ = false;
bool certs_loaded_ = false;
SystemCAMode system_ca_mode_ = SystemCAMode::Auto;
bool server_certificate_verification_ = true;
bool server_hostname_verification_ = true;
#endif
};
template <class Rep, class Period>
inline void WebSocketClient::set_read_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
}
template <class Rep, class Period>
inline void WebSocketClient::set_write_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_write_timeout(sec, usec); });
}
template <class Rep, class Period>
inline void WebSocketClient::set_connection_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_connection_timeout(sec, usec);
});
}
namespace impl {
bool is_valid_utf8(const std::string &s);