Golang net/http.Transport.CancelRequest() function example

package net/http

Golang net/http.Transport.CancelRequest() function usage example

 type transport struct {
 t http.Transport
 }

 func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
 timer := time.AfterFunc(*requestTimeout, func() {
 t.t.CancelRequest(req)
 log.Printf("Canceled request for %s", req.URL)
 })
 ...

Reference :

http://golang.org/pkg/net/http/#Transport.CancelRequest

Advertisement