This commit is contained in:
yhirose 2021-05-22 19:24:50 -04:00
parent 2917b8a005
commit ba34ea4ee8

View File

@ -804,10 +804,9 @@ enum class Error {
Compression, Compression,
}; };
inline std::ostream& operator << (std::ostream& os, const Error& obj) inline std::ostream &operator<<(std::ostream &os, const Error &obj) {
{ os << static_cast<std::underlying_type<Error>::type>(obj);
os << static_cast<std::underlying_type<Error>::type>(obj); return os;
return os;
} }
class Result { class Result {
@ -1625,7 +1624,7 @@ inline std::string encode_query_param(const std::string &value) {
inline std::string encode_url(const std::string &s) { inline std::string encode_url(const std::string &s) {
std::string result; std::string result;
result.reserve(s.size()); result.reserve(s.size());
for (size_t i = 0; s[i]; i++) { for (size_t i = 0; s[i]; i++) {
switch (s[i]) { switch (s[i]) {
case ' ': result += "%20"; break; case ' ': result += "%20"; break;
@ -3123,9 +3122,7 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider,
// Emit chunked response header and footer for each chunk // Emit chunked response header and footer for each chunk
auto chunk = auto chunk =
from_i_to_hex(payload.size()) + "\r\n" + payload + "\r\n"; from_i_to_hex(payload.size()) + "\r\n" + payload + "\r\n";
if (!write_data(strm, chunk.data(), chunk.size())) { if (!write_data(strm, chunk.data(), chunk.size())) { ok = false; }
ok = false;
}
} }
} else { } else {
ok = false; ok = false;
@ -6674,7 +6671,12 @@ inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
auto ret = SSL_read(ssl_, ptr, static_cast<int>(size)); auto ret = SSL_read(ssl_, ptr, static_cast<int>(size));
if (ret < 0) { if (ret < 0) {
auto err = SSL_get_error(ssl_, ret); auto err = SSL_get_error(ssl_, ret);
#ifdef _WIN32
while (err == SSL_ERROR_WANT_READ ||
err == SSL_ERROR_SYSCALL && WSAGetLastError() == WSAETIMEDOUT) {
#else
while (err == SSL_ERROR_WANT_READ) { while (err == SSL_ERROR_WANT_READ) {
#endif
if (SSL_pending(ssl_) > 0) { if (SSL_pending(ssl_) > 0) {
return SSL_read(ssl_, ptr, static_cast<int>(size)); return SSL_read(ssl_, ptr, static_cast<int>(size));
} else if (is_readable()) { } else if (is_readable()) {