Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Commit

Permalink
Set http.DefaultTransport if one is not provided to newNonceRoundTripper
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiangraz committed Nov 19, 2015
1 parent 61c9285 commit e44e71a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type nonceRoundTripper struct {
}

func newNonceRoundTripper(rt http.RoundTripper) *nonceRoundTripper {
if rt == nil {
rt = http.DefaultTransport
}
return &nonceRoundTripper{rt: rt, mu: new(sync.Mutex)}
}

Expand All @@ -40,11 +43,7 @@ func (nrt *nonceRoundTripper) Nonce() (string, error) {
}

func (nrt *nonceRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error) {
if nrt.rt == nil {
resp, err = http.DefaultTransport.RoundTrip(req)
} else {
resp, err = nrt.rt.RoundTrip(req)
}
resp, err = nrt.rt.RoundTrip(req)
if err != nil {
return
}
Expand All @@ -59,5 +58,6 @@ func (nrt *nonceRoundTripper) RoundTrip(req *http.Request) (resp *http.Response,
if len(nrt.nonces) < 2048 {
nrt.nonces = append(nrt.nonces, tok)
}

return
}

0 comments on commit e44e71a

Please sign in to comment.