From 03d393c7d9653b1cf6c901bd77ed1dd7f7005d50 Mon Sep 17 00:00:00 2001 From: masterElmar <18119527+masterElmar@users.noreply.github.com> Date: Thu, 30 Nov 2023 23:38:18 +0100 Subject: [PATCH] feat:#52 added lower timeout for http request --- backend/service/fetch/htmlDownloader.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/service/fetch/htmlDownloader.go b/backend/service/fetch/htmlDownloader.go index 8bd4d42..c69817e 100644 --- a/backend/service/fetch/htmlDownloader.go +++ b/backend/service/fetch/htmlDownloader.go @@ -4,14 +4,20 @@ import ( "fmt" "io" "net/http" + "time" ) // getPlanHTML Get the HTML document from the specified URL func GetHTML(url string) (string, error) { + // Create HTTP client with timeout of 5 seconds + client := http.Client{ + Timeout: 30 * time.Second, + } + // Send GET request - response, err := http.Get(url) + response, err := client.Get(url) if err != nil { fmt.Printf("Error occurred while making the request: %s\n", err.Error()) return "", err