mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Fix #1421
This commit is contained in:
parent
87994811a1
commit
07c6e58951
2 changed files with 133 additions and 89 deletions
38
httplib.h
38
httplib.h
|
@ -902,6 +902,7 @@ public:
|
|||
Result Head(const std::string &path, const Headers &headers);
|
||||
|
||||
Result Post(const std::string &path);
|
||||
Result Post(const std::string &path, const Headers &headers);
|
||||
Result Post(const std::string &path, const char *body, size_t content_length,
|
||||
const std::string &content_type);
|
||||
Result Post(const std::string &path, const Headers &headers, const char *body,
|
||||
|
@ -1263,6 +1264,7 @@ public:
|
|||
Result Head(const std::string &path, const Headers &headers);
|
||||
|
||||
Result Post(const std::string &path);
|
||||
Result Post(const std::string &path, const Headers &headers);
|
||||
Result Post(const std::string &path, const char *body, size_t content_length,
|
||||
const std::string &content_type);
|
||||
Result Post(const std::string &path, const Headers &headers, const char *body,
|
||||
|
@ -2877,19 +2879,19 @@ inline void get_remote_ip_and_port(socket_t sock, std::string &ip, int &port) {
|
|||
#ifndef _WIN32
|
||||
if (addr.ss_family == AF_UNIX) {
|
||||
#if defined(__linux__)
|
||||
struct ucred ucred;
|
||||
socklen_t len = sizeof(ucred);
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == 0) {
|
||||
port = ucred.pid;
|
||||
}
|
||||
#elif defined(SOL_LOCAL) && defined(SO_PEERPID) // __APPLE__
|
||||
pid_t pid;
|
||||
socklen_t len = sizeof(pid);
|
||||
if (getsockopt(sock, SOL_LOCAL, SO_PEERPID, &pid, &len) == 0) {
|
||||
port = pid;
|
||||
}
|
||||
struct ucred ucred;
|
||||
socklen_t len = sizeof(ucred);
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == 0) {
|
||||
port = ucred.pid;
|
||||
}
|
||||
#elif defined(SOL_LOCAL) && defined(SO_PEERPID) // __APPLE__
|
||||
pid_t pid;
|
||||
socklen_t len = sizeof(pid);
|
||||
if (getsockopt(sock, SOL_LOCAL, SO_PEERPID, &pid, &len) == 0) {
|
||||
port = pid;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
get_remote_ip_and_port(addr, addr_len, ip, port);
|
||||
|
@ -4745,7 +4747,7 @@ inline bool SocketStream::is_readable() const {
|
|||
|
||||
inline bool SocketStream::is_writable() const {
|
||||
return select_write(sock_, write_timeout_sec_, write_timeout_usec_) > 0 &&
|
||||
is_socket_alive(sock_);
|
||||
is_socket_alive(sock_);
|
||||
}
|
||||
|
||||
inline ssize_t SocketStream::read(char *ptr, size_t size) {
|
||||
|
@ -6752,6 +6754,11 @@ inline Result ClientImpl::Post(const std::string &path) {
|
|||
return Post(path, std::string(), std::string());
|
||||
}
|
||||
|
||||
inline Result ClientImpl::Post(const std::string &path,
|
||||
const Headers &headers) {
|
||||
return Post(path, headers, nullptr, 0, std::string());
|
||||
}
|
||||
|
||||
inline Result ClientImpl::Post(const std::string &path, const char *body,
|
||||
size_t content_length,
|
||||
const std::string &content_type) {
|
||||
|
@ -7369,7 +7376,7 @@ inline bool SSLSocketStream::is_readable() const {
|
|||
|
||||
inline bool SSLSocketStream::is_writable() const {
|
||||
return select_write(sock_, write_timeout_sec_, write_timeout_usec_) > 0 &&
|
||||
is_socket_alive(sock_);
|
||||
is_socket_alive(sock_);
|
||||
}
|
||||
|
||||
inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
|
||||
|
@ -8075,6 +8082,9 @@ inline Result Client::Head(const std::string &path, const Headers &headers) {
|
|||
}
|
||||
|
||||
inline Result Client::Post(const std::string &path) { return cli_->Post(path); }
|
||||
inline Result Client::Post(const std::string &path, const Headers &headers) {
|
||||
return cli_->Post(path, headers);
|
||||
}
|
||||
inline Result Client::Post(const std::string &path, const char *body,
|
||||
size_t content_length,
|
||||
const std::string &content_type) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue