cancelable_go14.go 426 B

12345678910111213141516171819
  1. // Copyright 2016 go-dockerclient 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. // +build !go1.5
  5. package docker
  6. import "net/http"
  7. func cancelable(client *http.Client, req *http.Request) func() {
  8. return func() {
  9. if rc, ok := client.Transport.(interface {
  10. CancelRequest(*http.Request)
  11. }); ok {
  12. rc.CancelRequest(req)
  13. }
  14. }
  15. }