|
@@ -183,6 +183,7 @@ using socket_t = SOCKET;
|
|
|
#include <pthread.h>
|
|
#include <pthread.h>
|
|
|
#include <sys/select.h>
|
|
#include <sys/select.h>
|
|
|
#include <sys/socket.h>
|
|
#include <sys/socket.h>
|
|
|
|
|
+#include <sys/un.h>
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
using socket_t = int;
|
|
using socket_t = int;
|
|
@@ -2570,6 +2571,30 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|
|
hints.ai_flags = socket_flags;
|
|
hints.ai_flags = socket_flags;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#ifndef _WIN32
|
|
|
|
|
+ if (hints.ai_family == AF_UNIX) {
|
|
|
|
|
+ const auto addrlen = host.length();
|
|
|
|
|
+ if (addrlen > sizeof(sockaddr_un::sun_path)) return INVALID_SOCKET;
|
|
|
|
|
+
|
|
|
|
|
+ auto sock = socket(hints.ai_family, hints.ai_socktype, hints.ai_protocol);
|
|
|
|
|
+ if (sock != INVALID_SOCKET) {
|
|
|
|
|
+ sockaddr_un addr;
|
|
|
|
|
+ addr.sun_family = AF_UNIX;
|
|
|
|
|
+ std::copy(host.begin(), host.end(), addr.sun_path);
|
|
|
|
|
+
|
|
|
|
|
+ hints.ai_addr = reinterpret_cast<sockaddr*>(&addr);
|
|
|
|
|
+ hints.ai_addrlen = static_cast<socklen_t>(
|
|
|
|
|
+ sizeof(addr) - sizeof(addr.sun_path) + addrlen);
|
|
|
|
|
+
|
|
|
|
|
+ if (!bind_or_connect(sock, hints)) {
|
|
|
|
|
+ close_socket(sock);
|
|
|
|
|
+ sock = INVALID_SOCKET;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return sock;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
auto service = std::to_string(port);
|
|
auto service = std::to_string(port);
|
|
|
|
|
|
|
|
if (getaddrinfo(node, service.c_str(), &hints, &result)) {
|
|
if (getaddrinfo(node, service.c_str(), &hints, &result)) {
|
|
@@ -7858,12 +7883,12 @@ inline Client::Client(const std::string &scheme_host_port,
|
|
|
|
|
|
|
|
if (is_ssl) {
|
|
if (is_ssl) {
|
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
- cli_ = detail::make_unique<SSLClient>(host.c_str(), port,
|
|
|
|
|
|
|
+ cli_ = detail::make_unique<SSLClient>(host, port,
|
|
|
client_cert_path, client_key_path);
|
|
client_cert_path, client_key_path);
|
|
|
is_ssl_ = is_ssl;
|
|
is_ssl_ = is_ssl;
|
|
|
#endif
|
|
#endif
|
|
|
} else {
|
|
} else {
|
|
|
- cli_ = detail::make_unique<ClientImpl>(host.c_str(), port,
|
|
|
|
|
|
|
+ cli_ = detail::make_unique<ClientImpl>(host, port,
|
|
|
client_cert_path, client_key_path);
|
|
client_cert_path, client_key_path);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|