1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // borrowed from golang/net/context/ctxhttp/cancelreq.go 6 7 package client 8 9 import "net/http" 10 11 func requestCanceler(tr CancelableTransport, req *http.Request) func() { 12 ch := make(chan struct{}) 13 req.Cancel = ch 14 15 return func() { 16 close(ch) 17 } 18 } 19