Don't use contexts in the request directly

This commit is contained in:
Xpl0itU 2024-04-14 16:34:45 +02:00
parent 5ce59468bf
commit 47136d878b

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -49,12 +50,12 @@ func downloadFileWithSemaphore(ctx context.Context, progressReporter ProgressRep
basePath := filepath.Base(dstPath) basePath := filepath.Base(dstPath)
for attempt := 1; attempt <= maxRetries; attempt++ { for attempt := 1; attempt <= maxRetries; attempt++ {
req, err := http.NewRequest("GET", downloadURL, nil) req := &http.Request{}
parsedURL, err := url.Parse(downloadURL)
if err != nil { if err != nil {
return err return err
} }
req.URL = parsedURL
req.Header.Set("User-Agent", "WiiUDownloader")
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {