mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fixed #150
This commit is contained in:
parent
48af26e332
commit
6f207497de
1 changed files with 13 additions and 2 deletions
15
httplib.h
15
httplib.h
|
@ -87,6 +87,8 @@ typedef int socket_t;
|
|||
#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND 5
|
||||
#define CPPHTTPLIB_KEEPALIVE_TIMEOUT_USECOND 0
|
||||
#define CPPHTTPLIB_KEEPALIVE_MAX_COUNT 5
|
||||
#define CPPHTTPLIB_READ_TIMEOUT_SECOND 5
|
||||
#define CPPHTTPLIB_READ_TIMEOUT_USECOND 0
|
||||
#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
|
||||
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH std::numeric_limits<size_t>::max()
|
||||
|
||||
|
@ -1432,7 +1434,11 @@ inline SocketStream::SocketStream(socket_t sock) : sock_(sock) {}
|
|||
inline SocketStream::~SocketStream() {}
|
||||
|
||||
inline int SocketStream::read(char *ptr, size_t size) {
|
||||
return recv(sock_, ptr, static_cast<int>(size), 0);
|
||||
if (detail::select_read(sock_, CPPHTTPLIB_READ_TIMEOUT_SECOND,
|
||||
CPPHTTPLIB_READ_TIMEOUT_USECOND) > 0) {
|
||||
return recv(sock_, ptr, static_cast<int>(size), 0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int SocketStream::write(const char *ptr, size_t size) {
|
||||
|
@ -2310,7 +2316,12 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl)
|
|||
inline SSLSocketStream::~SSLSocketStream() {}
|
||||
|
||||
inline int SSLSocketStream::read(char *ptr, size_t size) {
|
||||
return SSL_read(ssl_, ptr, size);
|
||||
if (SSL_pending(ssl_) > 0 ||
|
||||
detail::select_read(sock_, CPPHTTPLIB_READ_TIMEOUT_SECOND,
|
||||
CPPHTTPLIB_READ_TIMEOUT_USECOND) > 0) {
|
||||
return SSL_read(ssl_, ptr, size);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int SSLSocketStream::write(const char *ptr, size_t size) {
|
||||
|
|
Loading…
Reference in a new issue