mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:02:25 -05:00
[performance] Don't retry/backoff invalid http requests that will never succeed (#609)
* add httpguts (ew) * add ValidateRequest err wrapping logic * don't retry on unrecoverable errors * i am very clever
This commit is contained in:
parent
0f01f72db0
commit
1cdc163276
8 changed files with 487 additions and 4 deletions
|
|
@ -28,6 +28,9 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// ErrInvalidRequest is returned if a given HTTP request is invalid and cannot be performed.
|
||||
var ErrInvalidRequest = errors.New("invalid http request")
|
||||
|
||||
// ErrReservedAddr is returned if a dialed address resolves to an IP within a blocked or reserved net.
|
||||
var ErrReservedAddr = errors.New("dial within blocked / reserved IP range")
|
||||
|
||||
|
|
@ -164,6 +167,11 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
|
|||
defer func() { <-c.queue }()
|
||||
}
|
||||
|
||||
// Firstly, ensure this is a valid request
|
||||
if err := ValidateRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Perform the HTTP request
|
||||
rsp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue