70 case HttpErrorKind::ConnectRefused:
71 case HttpErrorKind::ConnectTimeout:
72 case HttpErrorKind::DnsTemporary:
73 case HttpErrorKind::ReadTimeout:
74 case HttpErrorKind::WriteTimeout:
75 case HttpErrorKind::PeerReset:
76 case HttpErrorKind::PeerEofEarly:
77 case HttpErrorKind::TlsHandshakeReset:
78 case HttpErrorKind::ServerError:
79 case HttpErrorKind::TooManyRequests:
81 case HttpErrorKind::DnsPermanent:
82 case HttpErrorKind::TlsVerifyFailed:
83 case HttpErrorKind::ProtocolError:
84 case HttpErrorKind::RequestTooLarge:
85 case HttpErrorKind::PayloadInvalid:
86 case HttpErrorKind::Unknown:
96 if (!ec)
return HttpErrorKind::Unknown;
98 const auto& cat = ec.category();
105 if (ec == asio::ssl::error::stream_truncated) {
106 return HttpErrorKind::PeerEofEarly;
108 if (cat == asio::error::get_ssl_category()) {
109 const int reason = ERR_GET_REASON(ec.value());
110 if (reason == SSL_R_CERTIFICATE_VERIFY_FAILED) {
111 return HttpErrorKind::TlsVerifyFailed;
113 return HttpErrorKind::TlsHandshakeReset;
124 if (ec == asio::error::connection_refused)
return HttpErrorKind::ConnectRefused;
125 if (ec == asio::error::timed_out)
return HttpErrorKind::ConnectTimeout;
126 if (ec == asio::error::connection_reset)
return HttpErrorKind::PeerReset;
127 if (ec == asio::error::broken_pipe)
return HttpErrorKind::PeerReset;
128 if (ec == asio::error::not_connected)
return HttpErrorKind::PeerReset;
129 if (ec == asio::error::eof)
return HttpErrorKind::PeerEofEarly;
130 if (ec == asio::error::host_not_found)
return HttpErrorKind::DnsPermanent;
131 if (ec == asio::error::host_not_found_try_again)
132 return HttpErrorKind::DnsTemporary;
140#if !defined(ASIO_WINDOWS) && !defined(_WIN32)
141 if (cat == asio::error::get_netdb_category()) {
142 return HttpErrorKind::DnsPermanent;
144 if (cat == asio::error::get_misc_category()) {
145 return HttpErrorKind::Unknown;
150 return HttpErrorKind::Unknown;
157 if (status >= 500 && status < 600)
return HttpErrorKind::ServerError;
158 if (status == 429)
return HttpErrorKind::TooManyRequests;
159 if (status == 413)
return HttpErrorKind::RequestTooLarge;
160 if (status >= 400 && status < 500)
return HttpErrorKind::PayloadInvalid;
161 return HttpErrorKind::Unknown;