mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
parent
4001637beb
commit
a5a62768c0
3 changed files with 23 additions and 23 deletions
30
httplib.h
30
httplib.h
|
@ -2708,9 +2708,9 @@ inline socket_t create_client_socket(
|
|||
[&](socket_t sock2, struct addrinfo &ai) -> bool {
|
||||
if (!intf.empty()) {
|
||||
#ifdef USE_IF2IP
|
||||
auto ip = if2ip(address_family, intf);
|
||||
if (ip.empty()) { ip = intf; }
|
||||
if (!bind_ip_address(sock2, ip.c_str())) {
|
||||
auto ip_from_if = if2ip(address_family, intf);
|
||||
if (ip_from_if.empty()) { ip_from_if = intf; }
|
||||
if (!bind_ip_address(sock2, ip_from_if.c_str())) {
|
||||
error = Error::BindIPAddress;
|
||||
return false;
|
||||
}
|
||||
|
@ -6320,8 +6320,8 @@ inline std::unique_ptr<Response> ClientImpl::send_with_content_provider(
|
|||
auto last = offset + data_len == content_length;
|
||||
|
||||
auto ret = compressor.compress(
|
||||
data, data_len, last, [&](const char *data, size_t data_len) {
|
||||
req.body.append(data, data_len);
|
||||
data, data_len, last, [&](const char *compressed_data, size_t compressed_data_len) {
|
||||
req.body.append(compressed_data, compressed_data_len);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -7378,11 +7378,11 @@ inline SSL_CTX *SSLServer::ssl_context() const { return ctx_; }
|
|||
inline bool SSLServer::process_and_close_socket(socket_t sock) {
|
||||
auto ssl = detail::ssl_new(
|
||||
sock, ctx_, ctx_mutex_,
|
||||
[&](SSL *ssl) {
|
||||
[&](SSL *ssl2) {
|
||||
return detail::ssl_connect_or_accept_nonblocking(
|
||||
sock, ssl, SSL_accept, read_timeout_sec_, read_timeout_usec_);
|
||||
sock, ssl2, SSL_accept, read_timeout_sec_, read_timeout_usec_);
|
||||
},
|
||||
[](SSL * /*ssl*/) { return true; });
|
||||
[](SSL * /*ssl2*/) { return true; });
|
||||
|
||||
bool ret = false;
|
||||
if (ssl) {
|
||||
|
@ -7576,31 +7576,31 @@ inline bool SSLClient::load_certs() {
|
|||
inline bool SSLClient::initialize_ssl(Socket &socket, Error &error) {
|
||||
auto ssl = detail::ssl_new(
|
||||
socket.sock, ctx_, ctx_mutex_,
|
||||
[&](SSL *ssl) {
|
||||
[&](SSL *ssl2) {
|
||||
if (server_certificate_verification_) {
|
||||
if (!load_certs()) {
|
||||
error = Error::SSLLoadingCerts;
|
||||
return false;
|
||||
}
|
||||
SSL_set_verify(ssl, SSL_VERIFY_NONE, nullptr);
|
||||
SSL_set_verify(ssl2, SSL_VERIFY_NONE, nullptr);
|
||||
}
|
||||
|
||||
if (!detail::ssl_connect_or_accept_nonblocking(
|
||||
socket.sock, ssl, SSL_connect, connection_timeout_sec_,
|
||||
socket.sock, ssl2, SSL_connect, connection_timeout_sec_,
|
||||
connection_timeout_usec_)) {
|
||||
error = Error::SSLConnection;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (server_certificate_verification_) {
|
||||
verify_result_ = SSL_get_verify_result(ssl);
|
||||
verify_result_ = SSL_get_verify_result(ssl2);
|
||||
|
||||
if (verify_result_ != X509_V_OK) {
|
||||
error = Error::SSLServerVerification;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto server_cert = SSL_get_peer_certificate(ssl);
|
||||
auto server_cert = SSL_get_peer_certificate(ssl2);
|
||||
|
||||
if (server_cert == nullptr) {
|
||||
error = Error::SSLServerVerification;
|
||||
|
@ -7617,8 +7617,8 @@ inline bool SSLClient::initialize_ssl(Socket &socket, Error &error) {
|
|||
|
||||
return true;
|
||||
},
|
||||
[&](SSL *ssl) {
|
||||
SSL_set_tlsext_host_name(ssl, host_.c_str());
|
||||
[&](SSL *ssl2) {
|
||||
SSL_set_tlsext_host_name(ssl2, host_.c_str());
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CXX = clang++
|
||||
CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address
|
||||
CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address
|
||||
|
||||
PREFIX = /usr/local
|
||||
#PREFIX = $(shell brew --prefix)
|
||||
|
|
14
test/test.cc
14
test/test.cc
|
@ -109,11 +109,11 @@ TEST(SplitTest, ParseQueryString) {
|
|||
detail::split(s.c_str(), s.c_str() + s.size(), '&',
|
||||
[&](const char *b, const char *e) {
|
||||
string key, val;
|
||||
detail::split(b, e, '=', [&](const char *b, const char *e) {
|
||||
detail::split(b, e, '=', [&](const char *b2, const char *e2) {
|
||||
if (key.empty()) {
|
||||
key.assign(b, e);
|
||||
key.assign(b2, e2);
|
||||
} else {
|
||||
val.assign(b, e);
|
||||
val.assign(b2, e2);
|
||||
}
|
||||
});
|
||||
dic.emplace(key, val);
|
||||
|
@ -3015,8 +3015,8 @@ TEST(GzipDecompressor, ChunkedDecompression) {
|
|||
httplib::detail::gzip_compressor compressor;
|
||||
bool result = compressor.compress(
|
||||
data.data(), data.size(),
|
||||
/*last=*/true, [&](const char *data, size_t size) {
|
||||
compressed_data.insert(compressed_data.size(), data, size);
|
||||
/*last=*/true, [&](const char *compressed_data_chunk, size_t compressed_data_size) {
|
||||
compressed_data.insert(compressed_data.size(), compressed_data_chunk, compressed_data_size);
|
||||
return true;
|
||||
});
|
||||
ASSERT_TRUE(result);
|
||||
|
@ -3035,8 +3035,8 @@ TEST(GzipDecompressor, ChunkedDecompression) {
|
|||
std::min(compressed_data.size() - chunk_begin, chunk_size);
|
||||
bool result = decompressor.decompress(
|
||||
compressed_data.data() + chunk_begin, current_chunk_size,
|
||||
[&](const char *data, size_t size) {
|
||||
decompressed_data.insert(decompressed_data.size(), data, size);
|
||||
[&](const char *decompressed_data_chunk, size_t decompressed_data_chunk_size) {
|
||||
decompressed_data.insert(decompressed_data.size(), decompressed_data_chunk, decompressed_data_chunk_size);
|
||||
return true;
|
||||
});
|
||||
ASSERT_TRUE(result);
|
||||
|
|
Loading…
Reference in a new issue