@@ -745,8 +745,11 @@ class Result {
745745 bool operator ==(std::nullptr_t ) const { return res_ == nullptr ; }
746746 bool operator !=(std::nullptr_t ) const { return res_ != nullptr ; }
747747 const Response &value () const { return *res_; }
748+ Response &value () { return *res_; }
748749 const Response &operator *() const { return *res_; }
750+ Response &operator *() { return *res_; }
749751 const Response *operator ->() const { return res_.get (); }
752+ Response *operator ->() { return res_.get (); }
750753 Error error () const { return err_; }
751754
752755private:
@@ -3164,7 +3167,7 @@ get_range_offset_and_length(const Request &req, size_t content_length,
31643167 auto slen = static_cast <ssize_t >(content_length);
31653168
31663169 if (r.first == -1 ) {
3167- r.first = std::max (static_cast <ssize_t >(0 ), slen - r.second );
3170+ r.first = ( std::max) (static_cast <ssize_t >(0 ), slen - r.second );
31683171 r.second = slen - 1 ;
31693172 }
31703173
@@ -5737,22 +5740,7 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl,
57375740 read_timeout_usec_(read_timeout_usec),
57385741 write_timeout_sec_(write_timeout_sec),
57395742 write_timeout_usec_(write_timeout_usec) {
5740- {
5741- timeval tv;
5742- tv.tv_sec = static_cast <long >(read_timeout_sec);
5743- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec);
5744-
5745- setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast <char *>(&tv),
5746- sizeof (tv));
5747- }
5748- {
5749- timeval tv;
5750- tv.tv_sec = static_cast <long >(write_timeout_sec);
5751- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(write_timeout_usec);
5752-
5753- setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast <char *>(&tv),
5754- sizeof (tv));
5755- }
5743+ SSL_clear_mode (ssl, SSL_MODE_AUTO_RETRY);
57565744}
57575745
57585746inline SSLSocketStream::~SSLSocketStream () {}
@@ -5767,8 +5755,27 @@ inline bool SSLSocketStream::is_writable() const {
57675755}
57685756
57695757inline ssize_t SSLSocketStream::read (char *ptr, size_t size) {
5770- if (SSL_pending (ssl_) > 0 || is_readable () ) {
5758+ if (SSL_pending (ssl_) > 0 ) {
57715759 return SSL_read (ssl_, ptr, static_cast <int >(size));
5760+ } else if (is_readable ()) {
5761+ auto ret = SSL_read (ssl_, ptr, static_cast <int >(size));
5762+ if (ret < 0 ) {
5763+ auto err = SSL_get_error (ssl_, ret);
5764+ while (err == SSL_ERROR_WANT_READ) {
5765+ if (SSL_pending (ssl_) > 0 ) {
5766+ return SSL_read (ssl_, ptr, static_cast <int >(size));
5767+ } else if (is_readable ()) {
5768+ ret = SSL_read (ssl_, ptr, static_cast <int >(size));
5769+ if (ret >= 0 ) {
5770+ return ret;
5771+ }
5772+ err = SSL_get_error (ssl_, ret);
5773+ } else {
5774+ return -1 ;
5775+ }
5776+ }
5777+ }
5778+ return ret;
57725779 }
57735780 return -1 ;
57745781}
0 commit comments