Opened https://github.com/golang/oauth2/issues/487 to propose removing the `CancelRequest` method.
Cheers, Andreas On Friday, March 19, 2021 at 5:44:21 PM UTC+1 cpu...@gmail.com wrote: > Hi all, > > I've recently learned about oauth2 and started to convert some of my > "manual" code using net/http to use an underlying oauth2.Transport for > executing authenticated requests and token refresh. > > As a result, my application now sometimes shows > > deprecated: golang.org/x/oauth2: Transport.CancelRequest no longer > does anything; use contexts > > Of course, I'm nowhere calling that method. Digging into the default HTTP > Client ( > https://github.com/golang/go/blob/a937729c2c2f6950a32bc5cd0f5b88700882f078/src/net/http/client.go) > > reads: > > // For compatibility, the Client will also use the deprecated > // CancelRequest method on Transport if found. New > // RoundTripper implementations should use the Request's Context > // for cancellation instead of implementing CancelRequest. > Timeout time.Duration > > I would read this as: if you have an http.Client with an underlying > oauth2.Transport and the request times out, the oauth2.Transport's > CancelRequest method will *always* be called and hence show the undesired > warning. > > Is that correct? > > Thanks, > Andreas > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/76840e3d-f555-4be1-baa7-78aa2f98d1d8n%40googlegroups.com.