mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-25 14:09:10 +00:00
Detect if afunix.h exists (#2145)
Some checks failed
test / windows compiled (push) Has been cancelled
abidiff / abi (push) Has been cancelled
test / style-check (push) Has been cancelled
test / ubuntu (32-bit) (push) Has been cancelled
test / ubuntu (64-bit) (push) Has been cancelled
test / macos (push) Has been cancelled
test / windows with SSL (push) Has been cancelled
test / windows without SSL (push) Has been cancelled
Some checks failed
test / windows compiled (push) Has been cancelled
abidiff / abi (push) Has been cancelled
test / style-check (push) Has been cancelled
test / ubuntu (32-bit) (push) Has been cancelled
test / ubuntu (64-bit) (push) Has been cancelled
test / macos (push) Has been cancelled
test / windows with SSL (push) Has been cancelled
test / windows without SSL (push) Has been cancelled
Signed-off-by: Piotr Stankiewicz <piotr.stankiewicz@docker.com>
This commit is contained in:
parent
fd324e1412
commit
4a7aae5469
1 changed files with 7 additions and 0 deletions
|
@ -192,8 +192,13 @@ using ssize_t = long;
|
|||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<afunix.h>)
|
||||
// afunix.h uses types declared in winsock2.h, so has to be included after it.
|
||||
#include <afunix.h>
|
||||
#define CPPHTTPLIB_HAVE_AFUNIX_H 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef WSA_FLAG_NO_HANDLE_INHERIT
|
||||
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
|
||||
|
@ -3551,6 +3556,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|||
hints.ai_flags = socket_flags;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || defined(CPPHTTPLIB_HAVE_AFUNIX_H)
|
||||
if (hints.ai_family == AF_UNIX) {
|
||||
const auto addrlen = host.length();
|
||||
if (addrlen > sizeof(sockaddr_un::sun_path)) { return INVALID_SOCKET; }
|
||||
|
@ -3595,6 +3601,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|||
}
|
||||
return sock;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto service = std::to_string(port);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue