update httplib to 0.16.0
This commit is contained in:
+1
-1
Submodule auth_service_cpp updated: 8abb0a901a...8accbdc476
@@ -8,7 +8,7 @@
|
|||||||
#ifndef CPPHTTPLIB_HTTPLIB_H
|
#ifndef CPPHTTPLIB_HTTPLIB_H
|
||||||
#define CPPHTTPLIB_HTTPLIB_H
|
#define CPPHTTPLIB_HTTPLIB_H
|
||||||
|
|
||||||
#define CPPHTTPLIB_VERSION "0.15.3"
|
#define CPPHTTPLIB_VERSION "0.16.0"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configuration
|
* Configuration
|
||||||
@@ -726,6 +726,10 @@ private:
|
|||||||
assert(true == static_cast<bool>(fn));
|
assert(true == static_cast<bool>(fn));
|
||||||
fn();
|
fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
|
OPENSSL_thread_stop ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool &pool_;
|
ThreadPool &pool_;
|
||||||
@@ -1526,6 +1530,7 @@ public:
|
|||||||
const std::string &client_key_path);
|
const std::string &client_key_path);
|
||||||
|
|
||||||
Client(Client &&) = default;
|
Client(Client &&) = default;
|
||||||
|
Client &operator=(Client &&) = default;
|
||||||
|
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
@@ -1819,6 +1824,9 @@ public:
|
|||||||
bool is_valid() const override;
|
bool is_valid() const override;
|
||||||
|
|
||||||
SSL_CTX *ssl_context() const;
|
SSL_CTX *ssl_context() const;
|
||||||
|
|
||||||
|
void update_certs (X509 *cert, EVP_PKEY *private_key,
|
||||||
|
X509_STORE *client_ca_cert_store = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool process_and_close_socket(socket_t sock) override;
|
bool process_and_close_socket(socket_t sock) override;
|
||||||
@@ -2816,24 +2824,47 @@ inline bool mmap::open(const char *path) {
|
|||||||
wpath += path[i];
|
wpath += path[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||||
hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||||
OPEN_EXISTING, NULL);
|
OPEN_EXISTING, NULL);
|
||||||
|
#else
|
||||||
|
hFile_ = ::CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
|
||||||
LARGE_INTEGER size{};
|
LARGE_INTEGER size{};
|
||||||
if (!::GetFileSizeEx(hFile_, &size)) { return false; }
|
if (!::GetFileSizeEx(hFile_, &size)) { return false; }
|
||||||
size_ = static_cast<size_t>(size.QuadPart);
|
size_ = static_cast<size_t>(size.QuadPart);
|
||||||
|
#else
|
||||||
|
DWORD sizeHigh;
|
||||||
|
DWORD sizeLow;
|
||||||
|
sizeLow = ::GetFileSize(hFile_, &sizeHigh);
|
||||||
|
if (sizeLow == INVALID_FILE_SIZE) { return false; }
|
||||||
|
size_ = (static_cast<size_t>(sizeHigh) << (sizeof(DWORD) * 8)) | sizeLow;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||||
hMapping_ =
|
hMapping_ =
|
||||||
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
||||||
|
#else
|
||||||
|
hMapping_ =
|
||||||
|
::CreateFileMappingW(hFile_, NULL, PAGE_READONLY, size.HighPart,
|
||||||
|
size.LowPart, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hMapping_ == NULL) {
|
if (hMapping_ == NULL) {
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||||
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
||||||
|
#else
|
||||||
|
addr_ = ::MapViewOfFile(hMapping_, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
fd_ = ::open(path, O_RDONLY);
|
fd_ = ::open(path, O_RDONLY);
|
||||||
if (fd_ == -1) { return false; }
|
if (fd_ == -1) { return false; }
|
||||||
@@ -7268,7 +7299,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
|
|||||||
if (location.empty()) { return false; }
|
if (location.empty()) { return false; }
|
||||||
|
|
||||||
const static std::regex re(
|
const static std::regex re(
|
||||||
R"((?:(https?):)?(?://(?:\[([\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\?[^#]*)?(?:#.*)?)");
|
R"((?:(https?):)?(?://(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\?[^#]*)?(?:#.*)?)");
|
||||||
|
|
||||||
std::smatch m;
|
std::smatch m;
|
||||||
if (!std::regex_match(location, m, re)) { return false; }
|
if (!std::regex_match(location, m, re)) { return false; }
|
||||||
@@ -8687,7 +8718,7 @@ inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path,
|
|||||||
SSL_OP_NO_COMPRESSION |
|
SSL_OP_NO_COMPRESSION |
|
||||||
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
|
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
|
||||||
|
|
||||||
SSL_CTX_set_min_proto_version(ctx_, TLS1_1_VERSION);
|
SSL_CTX_set_min_proto_version(ctx_, TLS1_2_VERSION);
|
||||||
|
|
||||||
if (private_key_password != nullptr && (private_key_password[0] != '\0')) {
|
if (private_key_password != nullptr && (private_key_password[0] != '\0')) {
|
||||||
SSL_CTX_set_default_passwd_cb_userdata(
|
SSL_CTX_set_default_passwd_cb_userdata(
|
||||||
@@ -8719,7 +8750,7 @@ inline SSLServer::SSLServer(X509 *cert, EVP_PKEY *private_key,
|
|||||||
SSL_OP_NO_COMPRESSION |
|
SSL_OP_NO_COMPRESSION |
|
||||||
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
|
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
|
||||||
|
|
||||||
SSL_CTX_set_min_proto_version(ctx_, TLS1_1_VERSION);
|
SSL_CTX_set_min_proto_version(ctx_, TLS1_2_VERSION);
|
||||||
|
|
||||||
if (SSL_CTX_use_certificate(ctx_, cert) != 1 ||
|
if (SSL_CTX_use_certificate(ctx_, cert) != 1 ||
|
||||||
SSL_CTX_use_PrivateKey(ctx_, private_key) != 1) {
|
SSL_CTX_use_PrivateKey(ctx_, private_key) != 1) {
|
||||||
@@ -8753,6 +8784,19 @@ inline bool SSLServer::is_valid() const { return ctx_; }
|
|||||||
|
|
||||||
inline SSL_CTX *SSLServer::ssl_context() const { return ctx_; }
|
inline SSL_CTX *SSLServer::ssl_context() const { return ctx_; }
|
||||||
|
|
||||||
|
inline void SSLServer::update_certs (X509 *cert, EVP_PKEY *private_key,
|
||||||
|
X509_STORE *client_ca_cert_store) {
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> guard(ctx_mutex_);
|
||||||
|
|
||||||
|
SSL_CTX_use_certificate (ctx_, cert);
|
||||||
|
SSL_CTX_use_PrivateKey (ctx_, private_key);
|
||||||
|
|
||||||
|
if (client_ca_cert_store != nullptr) {
|
||||||
|
SSL_CTX_set_cert_store (ctx_, client_ca_cert_store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline bool SSLServer::process_and_close_socket(socket_t sock) {
|
inline bool SSLServer::process_and_close_socket(socket_t sock) {
|
||||||
auto ssl = detail::ssl_new(
|
auto ssl = detail::ssl_new(
|
||||||
sock, ctx_, ctx_mutex_,
|
sock, ctx_, ctx_mutex_,
|
||||||
@@ -9213,7 +9257,7 @@ inline Client::Client(const std::string &scheme_host_port,
|
|||||||
const std::string &client_cert_path,
|
const std::string &client_cert_path,
|
||||||
const std::string &client_key_path) {
|
const std::string &client_key_path) {
|
||||||
const static std::regex re(
|
const static std::regex re(
|
||||||
R"((?:([a-z]+):\/\/)?(?:\[([\d:]+)\]|([^:/?#]+))(?::(\d+))?)");
|
R"((?:([a-z]+):\/\/)?(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)");
|
||||||
|
|
||||||
std::smatch m;
|
std::smatch m;
|
||||||
if (std::regex_match(scheme_host_port, m, re)) {
|
if (std::regex_match(scheme_host_port, m, re)) {
|
||||||
@@ -9250,6 +9294,8 @@ inline Client::Client(const std::string &scheme_host_port,
|
|||||||
client_key_path);
|
client_key_path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// NOTE: Update TEST(UniversalClientImplTest, Ipv6LiteralAddress)
|
||||||
|
// if port param below changes.
|
||||||
cli_ = detail::make_unique<ClientImpl>(scheme_host_port, 80,
|
cli_ = detail::make_unique<ClientImpl>(scheme_host_port, 80,
|
||||||
client_cert_path, client_key_path);
|
client_cert_path, client_key_path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user