Use context.WithTimeout instead of transport.Deadline

* The field was removed in,
   11ed51af43
This commit is contained in:
Arlo Breault 2017-10-12 18:12:11 -04:00
parent ab4bd77cb4
commit fea9df7540

View file

@ -74,14 +74,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
if urlFetchTimeout != 0 {
context_, _ = context.WithTimeout(context_, urlFetchTimeout)
}
// Use urlfetch.Transport directly instead of urlfetch.Client because we // Use urlfetch.Transport directly instead of urlfetch.Client because we
// want only a single HTTP transaction, not following redirects. // want only a single HTTP transaction, not following redirects.
transport := urlfetch.Transport{ transport := urlfetch.Transport{
Context: context_, Context: context_,
// Despite the name, Transport.Deadline is really a timeout and
// not an absolute deadline as used in the net package. In
// other words it is a time.Duration, not a time.Time.
Deadline: urlFetchTimeout,
} }
resp, err := transport.RoundTrip(fr) resp, err := transport.RoundTrip(fr)
if err != nil { if err != nil {