[bugfix] Add back removed ValidateRequest() before backoff-retry loop (#1805)

* add back removed ValidateRequest() before backoff-retry loop

Signed-off-by: kim <grufwub@gmail.com>

* include response body in error response log

Signed-off-by: kim <grufwub@gmail.com>

* improved error response body draining

Signed-off-by: kim <grufwub@gmail.com>

* add more code commenting

Signed-off-by: kim <grufwub@gmail.com>

* move new error response logic to gtserror, handle instead in transport.Transport{} impl

Signed-off-by: kim <grufwub@gmail.com>

* appease ye oh mighty linter

Signed-off-by: kim <grufwub@gmail.com>

* fix mockhttpclient not setting request in http response

Signed-off-by: kim <grufwub@gmail.com>

---------

Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2023-05-21 17:59:14 +01:00 committed by GitHub
commit 2063d01cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 299 additions and 32 deletions

View file

@ -19,7 +19,6 @@ package transport
import (
"context"
"fmt"
"net/http"
"net/url"
"sync"
@ -131,8 +130,7 @@ func (t *transport) deliver(ctx context.Context, b []byte, to *url.URL) error {
if code := rsp.StatusCode; code != http.StatusOK &&
code != http.StatusCreated && code != http.StatusAccepted {
err := fmt.Errorf("POST request to %s failed: %s", url, rsp.Status)
return gtserror.WithStatusCode(err, rsp.StatusCode)
return gtserror.NewResponseError(rsp)
}
return nil