mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Fixed #29
This commit is contained in:
parent
6a608b3ed4
commit
929c546f17
20
httplib.h
20
httplib.h
@ -8,7 +8,7 @@
|
|||||||
#ifndef _CPPHTTPLIB_HTTPLIB_H_
|
#ifndef _CPPHTTPLIB_HTTPLIB_H_
|
||||||
#define _CPPHTTPLIB_HTTPLIB_H_
|
#define _CPPHTTPLIB_HTTPLIB_H_
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#endif //_CRT_SECURE_NO_WARNINGS
|
#endif //_CRT_SECURE_NO_WARNINGS
|
||||||
@ -60,6 +60,14 @@ typedef int socket_t;
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include(<openssl/ssl.h>)
|
||||||
|
#ifndef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
|
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -357,7 +365,7 @@ inline void socket_printf(Stream& strm, const char* fmt, const Args& ...args)
|
|||||||
|
|
||||||
inline int close_socket(socket_t sock)
|
inline int close_socket(socket_t sock)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
return closesocket(sock);
|
return closesocket(sock);
|
||||||
#else
|
#else
|
||||||
return close(sock);
|
return close(sock);
|
||||||
@ -375,7 +383,7 @@ inline bool read_and_close_socket(socket_t sock, T callback)
|
|||||||
|
|
||||||
inline int shutdown_socket(socket_t sock)
|
inline int shutdown_socket(socket_t sock)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
return shutdown(sock, SD_BOTH);
|
return shutdown(sock, SD_BOTH);
|
||||||
#else
|
#else
|
||||||
return shutdown(sock, SHUT_RDWR);
|
return shutdown(sock, SHUT_RDWR);
|
||||||
@ -385,7 +393,7 @@ inline int shutdown_socket(socket_t sock)
|
|||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0)
|
socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
int opt = SO_SYNCHRONOUS_NONALERT;
|
int opt = SO_SYNCHRONOUS_NONALERT;
|
||||||
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char*)&opt, sizeof(opt));
|
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char*)&opt, sizeof(opt));
|
||||||
#endif
|
#endif
|
||||||
@ -999,7 +1007,7 @@ inline bool parse_multipart_formdata(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
class WSInit {
|
class WSInit {
|
||||||
public:
|
public:
|
||||||
WSInit() {
|
WSInit() {
|
||||||
@ -1123,7 +1131,7 @@ inline int SocketStream::write(const char* ptr)
|
|||||||
inline Server::Server()
|
inline Server::Server()
|
||||||
: svr_sock_(-1)
|
: svr_sock_(-1)
|
||||||
{
|
{
|
||||||
#ifndef _MSC_VER
|
#ifndef _WIN32
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user