mirror of
https://github.com/yhirose/cpp-httplib
synced 2026-06-08 18:30:49 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c7554ccac2 | |||
| 35ef1c7bae |
@@ -746,6 +746,12 @@ res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
|
||||
res->body; // Compressed data
|
||||
```
|
||||
|
||||
Use `poll` instead of `select`
|
||||
------------------------------
|
||||
|
||||
`select` system call is used as default since it's more widely supported. If you want to let cpp-httplib use `poll` instead, you can do so with `CPPHTTPLIB_USE_POLL`.
|
||||
|
||||
|
||||
Split httplib.h into .h and .cc
|
||||
-------------------------------
|
||||
|
||||
|
||||
@@ -6997,7 +6997,30 @@ inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
|
||||
}
|
||||
|
||||
inline ssize_t SSLSocketStream::write(const char *ptr, size_t size) {
|
||||
if (is_writable()) { return SSL_write(ssl_, ptr, static_cast<int>(size)); }
|
||||
if (is_writable()) {
|
||||
auto ret = SSL_write(ssl_, ptr, static_cast<int>(size));
|
||||
if (ret < 0) {
|
||||
auto err = SSL_get_error(ssl_, ret);
|
||||
int n = 1000;
|
||||
#ifdef _WIN32
|
||||
while (--n >= 0 &&
|
||||
(err == SSL_ERROR_WANT_WRITE ||
|
||||
err == SSL_ERROR_SYSCALL && WSAGetLastError() == WSAETIMEDOUT)) {
|
||||
#else
|
||||
while (--n >= 0 && err == SSL_ERROR_WANT_WRITE) {
|
||||
#endif
|
||||
if (is_writable()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
ret = SSL_write(ssl_, ptr, static_cast<int>(size));
|
||||
if (ret >= 0) { return ret; }
|
||||
err = SSL_get_error(ssl_, ret);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user