diff options
Diffstat (limited to 'provider.go')
-rw-r--r-- | provider.go | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/provider.go b/provider.go index a4aab8a..bba9efc 100644 --- a/provider.go +++ b/provider.go @@ -36,6 +36,11 @@ func (p Provider) RoundTrip(req *http.Request) (*http.Response, error) { if nonce != "" && len(p.nonces) < cap(p.nonces) { p.nonces <- nonce } + // not sure if it belongs here + if hasProblem(resp) { + defer resp.Body.Close() + return nil, problem(resp.Body) + } return resp, nil } @@ -68,27 +73,11 @@ func (p *Provider) post(uri string, s Signer, v interface{}) (*http.Response, er if err != nil { return nil, err } - resp, err := p.Post(uri, "application/jose+json", signed) - if err != nil { - return nil, err - } - if hasProblem(resp) { - defer resp.Body.Close() - return nil, problem(resp.Body) - } - return resp, nil + return p.Post(uri, "application/jose+json", signed) } func (p *Provider) get(uri string) (*http.Response, error) { - resp, err := p.Get(uri) - if err != nil { - return nil, err - } - if hasProblem(resp) { - defer resp.Body.Close() - return nil, problem(resp.Body) - } - return resp, nil + return p.Get(uri) } type nextStep struct { |