From 47136d878b85182937b15c99b6fed42585bf489b Mon Sep 17 00:00:00 2001 From: Xpl0itU <24777100+Xpl0itU@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:34:45 +0200 Subject: [PATCH] Don't use contexts in the request directly --- downloader.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/downloader.go b/downloader.go index ba11b0c..29b2971 100644 --- a/downloader.go +++ b/downloader.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "path/filepath" "strings" @@ -49,12 +50,12 @@ func downloadFileWithSemaphore(ctx context.Context, progressReporter ProgressRep basePath := filepath.Base(dstPath) for attempt := 1; attempt <= maxRetries; attempt++ { - req, err := http.NewRequest("GET", downloadURL, nil) + req := &http.Request{} + parsedURL, err := url.Parse(downloadURL) if err != nil { return err } - - req.Header.Set("User-Agent", "WiiUDownloader") + req.URL = parsedURL resp, err := client.Do(req) if err != nil {