diff options
author | 2023-04-30 09:11:18 +0100 | |
---|---|---|
committer | 2023-04-30 10:11:18 +0200 | |
commit | ead286a67b48d4f2f8dbee737e48aab178ac34aa (patch) | |
tree | 0263740d681f45c5759a33382e8a07c0ee8a6cc7 /internal/httpclient | |
parent | [performance] tweak http client error handling (#1718) (diff) | |
download | gotosocial-ead286a67b48d4f2f8dbee737e48aab178ac34aa.tar.xz |
[bugfix] tweak httpclient error handling again ... (#1721)
* check for tls, x509 errors using string.Contains() since crypto/tls sucks
Signed-off-by: kim <grufwub@gmail.com>
* use 2* maxprocs
Signed-off-by: kim <grufwub@gmail.com>
---------
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/httpclient')
-rw-r--r-- | internal/httpclient/client.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/internal/httpclient/client.go b/internal/httpclient/client.go index 68e11495d..dd1a1bd6b 100644 --- a/internal/httpclient/client.go +++ b/internal/httpclient/client.go @@ -19,7 +19,6 @@ package httpclient import ( "context" - "crypto/x509" "errors" "fmt" "io" @@ -266,15 +265,13 @@ func (c *Client) DoSigned(r *http.Request, sign SignFunc) (rsp *http.Response, e ) { // Non-retryable errors. return nil, err - } else if errorsv2.Assignable(err, - (*x509.CertificateInvalidError)(nil), - (*x509.HostnameError)(nil), - (*x509.UnknownAuthorityError)(nil), - ) { - // Non-retryable TLS errors. - return nil, err - } else if strings.Contains(err.Error(), "stopped after 10 redirects") { - // Don't bother if net/http returned after too many redirects + } else if errstr := err.Error(); // nocollapse + strings.Contains(errstr, "stopped after 10 redirects") || + strings.Contains(errstr, "tls: ") || + strings.Contains(errstr, "x509: ") { + // These error types aren't wrapped + // so we have to check the error string. + // All are unrecoverable! return nil, err } else if dnserr := (*net.DNSError)(nil); // nocollapse errors.As(err, &dnserr) && dnserr.IsNotFound { |