mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
resources: Add timeout to the HTTP request in Get
Workaround for https://github.com/golang/go/issues/49366
This commit is contained in:
@@ -18,6 +18,7 @@ package create
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -180,6 +181,14 @@ func (c *Client) FromRemote(uri string, options map[string]interface{}) (resourc
|
||||
}
|
||||
addUserProvidedHeaders(headers, req)
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/golang/go/issues/49366
|
||||
// This is the entire lifetime of the request.
|
||||
ctx, cancel := context.WithTimeout(req.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
res, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user