68 case HttpErrorKind::ConnectRefused:
69 case HttpErrorKind::ConnectTimeout:
70 case HttpErrorKind::DnsTemporary:
71 case HttpErrorKind::ReadTimeout:
72 case HttpErrorKind::WriteTimeout:
73 case HttpErrorKind::PeerReset:
74 case HttpErrorKind::PeerEofEarly:
75 case HttpErrorKind::TlsHandshakeReset:
76 case HttpErrorKind::ServerError:
77 case HttpErrorKind::TooManyRequests:
79 case HttpErrorKind::DnsPermanent:
80 case HttpErrorKind::TlsVerifyFailed:
81 case HttpErrorKind::ProtocolError:
82 case HttpErrorKind::RequestTooLarge:
83 case HttpErrorKind::PayloadInvalid:
84 case HttpErrorKind::Unknown:
94 if (!ec)
return HttpErrorKind::Unknown;
96 const auto& cat = ec.category();
103 if (ec == asio::ssl::error::stream_truncated) {
104 return HttpErrorKind::PeerEofEarly;
106 if (cat == asio::error::get_ssl_category()) {
107 const int reason = ERR_GET_REASON(ec.value());
108 if (reason == SSL_R_CERTIFICATE_VERIFY_FAILED) {
109 return HttpErrorKind::TlsVerifyFailed;
111 return HttpErrorKind::TlsHandshakeReset;
122 if (ec == asio::error::connection_refused)
return HttpErrorKind::ConnectRefused;
123 if (ec == asio::error::timed_out)
return HttpErrorKind::ConnectTimeout;
124 if (ec == asio::error::connection_reset)
return HttpErrorKind::PeerReset;
125 if (ec == asio::error::broken_pipe)
return HttpErrorKind::PeerReset;
126 if (ec == asio::error::not_connected)
return HttpErrorKind::PeerReset;
127 if (ec == asio::error::eof)
return HttpErrorKind::PeerEofEarly;
128 if (ec == asio::error::host_not_found)
return HttpErrorKind::DnsPermanent;
129 if (ec == asio::error::host_not_found_try_again)
130 return HttpErrorKind::DnsTemporary;
138#if !defined(ASIO_WINDOWS) && !defined(_WIN32)
139 if (cat == asio::error::get_netdb_category()) {
140 return HttpErrorKind::DnsPermanent;
142 if (cat == asio::error::get_misc_category()) {
143 return HttpErrorKind::Unknown;
148 return HttpErrorKind::Unknown;
155 if (status >= 500 && status < 600)
return HttpErrorKind::ServerError;
156 if (status == 429)
return HttpErrorKind::TooManyRequests;
157 if (status == 413)
return HttpErrorKind::RequestTooLarge;
158 if (status >= 400 && status < 500)
return HttpErrorKind::PayloadInvalid;
159 return HttpErrorKind::Unknown;