1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00

Fix dowloading timeout configuration

This commit is contained in:
DarthSim 2017-11-14 02:28:04 +06:00
parent 089744250c
commit f9fbfefad6
2 changed files with 8 additions and 3 deletions

View File

@ -188,4 +188,5 @@ func init() {
}
initVips()
initDownloading()
}

View File

@ -18,9 +18,7 @@ import (
_ "golang.org/x/image/webp"
)
var downloadClient = http.Client{
Timeout: time.Duration(conf.DownloadTimeout) * time.Second,
}
var downloadClient *http.Client
type netReader struct {
reader *bufio.Reader
@ -57,6 +55,12 @@ func (r *netReader) GrowBuf(s int) {
r.buf.Grow(s)
}
func initDownloading() {
downloadClient = &http.Client{
Timeout: time.Duration(conf.DownloadTimeout) * time.Second,
}
}
func checkTypeAndDimensions(r io.Reader) (imageType, error) {
imgconf, imgtypeStr, err := image.DecodeConfig(r)
imgtype, imgtypeOk := imageTypes[imgtypeStr]