From 12e8bc7b09e465eb61f34af62b2888378a46a1df Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Mon, 6 Aug 2018 11:51:13 -0400 Subject: [PATCH] add CancelRequest to discovery round-tripper Kubernetes-commit: 07eae3a1725c65860d85956f4fda20293a8d0a9e --- discovery/round_tripper.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/discovery/round_tripper.go b/discovery/round_tripper.go index a195d2a2..75b7f520 100644 --- a/discovery/round_tripper.go +++ b/discovery/round_tripper.go @@ -20,6 +20,7 @@ import ( "net/http" "path/filepath" + "github.com/golang/glog" "github.com/gregjones/httpcache" "github.com/gregjones/httpcache/diskcache" "github.com/peterbourgon/diskv" @@ -47,4 +48,15 @@ func (rt *cacheRoundTripper) RoundTrip(req *http.Request) (*http.Response, error return rt.rt.RoundTrip(req) } +func (rt *cacheRoundTripper) CancelRequest(req *http.Request) { + type canceler interface { + CancelRequest(*http.Request) + } + if cr, ok := rt.rt.Transport.(canceler); ok { + cr.CancelRequest(req) + } else { + glog.Errorf("CancelRequest not implemented by %T", rt.rt.Transport) + } +} + func (rt *cacheRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt.Transport }