cancelreq.go 405 B

123456789101112131415161718
  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. // borrowed from golang/net/context/ctxhttp/cancelreq.go
  5. package client
  6. import "net/http"
  7. func requestCanceler(tr CancelableTransport, req *http.Request) func() {
  8. ch := make(chan struct{})
  9. req.Cancel = ch
  10. return func() {
  11. close(ch)
  12. }
  13. }