From 1ecdfc2ba5184f8291aff5436f2f93e105904d42 Mon Sep 17 00:00:00 2001 From: Lucas BEE Date: Wed, 17 Apr 2019 17:30:41 +0200 Subject: [PATCH] web: Add timeout on get requests --- backend/web/download.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/web/download.go b/backend/web/download.go index 6002d3f..d9d90e3 100644 --- a/backend/web/download.go +++ b/backend/web/download.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "path" + "time" "github.com/nfnt/resize" ) @@ -17,7 +18,10 @@ var Download = func(srcURL, dest string) error { return err } - resp, err := http.Get(srcURL) + var httpClient = &http.Client{ + Timeout: time.Second * 10, + } + resp, err := httpClient.Get(srcURL) if err != nil { return err }