mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 11:46:40 +00:00
[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>
This commit is contained in:
parent
68b91d2128
commit
ead286a67b
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/x509"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -266,15 +265,13 @@ func (c *Client) DoSigned(r *http.Request, sign SignFunc) (rsp *http.Response, e
|
||||||
) {
|
) {
|
||||||
// Non-retryable errors.
|
// Non-retryable errors.
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if errorsv2.Assignable(err,
|
} else if errstr := err.Error(); // nocollapse
|
||||||
(*x509.CertificateInvalidError)(nil),
|
strings.Contains(errstr, "stopped after 10 redirects") ||
|
||||||
(*x509.HostnameError)(nil),
|
strings.Contains(errstr, "tls: ") ||
|
||||||
(*x509.UnknownAuthorityError)(nil),
|
strings.Contains(errstr, "x509: ") {
|
||||||
) {
|
// These error types aren't wrapped
|
||||||
// Non-retryable TLS errors.
|
// so we have to check the error string.
|
||||||
return nil, err
|
// All are unrecoverable!
|
||||||
} else if strings.Contains(err.Error(), "stopped after 10 redirects") {
|
|
||||||
// Don't bother if net/http returned after too many redirects
|
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if dnserr := (*net.DNSError)(nil); // nocollapse
|
} else if dnserr := (*net.DNSError)(nil); // nocollapse
|
||||||
errors.As(err, &dnserr) && dnserr.IsNotFound {
|
errors.As(err, &dnserr) && dnserr.IsNotFound {
|
||||||
|
|
|
@ -69,7 +69,7 @@ func NewController(state *state.State, federatingDB federatingdb.DB, clock pub.C
|
||||||
client: client,
|
client: client,
|
||||||
trspCache: cache.New[string, *transport](0, 100, 0),
|
trspCache: cache.New[string, *transport](0, 100, 0),
|
||||||
userAgent: fmt.Sprintf("%s (+%s://%s) gotosocial/%s", applicationName, proto, host, version),
|
userAgent: fmt.Sprintf("%s (+%s://%s) gotosocial/%s", applicationName, proto, host, version),
|
||||||
senders: runtime.GOMAXPROCS(0), // on batch delivery, only ever send GOMAXPROCS at a time.
|
senders: 2 * runtime.GOMAXPROCS(0), // on batch delivery, only ever send 2*GOMAXPROCS at a time.
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
|
|
Loading…
Reference in a new issue