env: supports for http and socks5 proxies

This commit is contained in:
stefanodvx 2025-04-14 21:50:49 +02:00
parent 386c3991cd
commit 10c113f400
10 changed files with 51 additions and 60 deletions

View file

@ -12,14 +12,7 @@ import (
"govd/util"
)
var HTTPClient = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return fmt.Errorf("stopped after 10 redirects")
}
return nil
},
}
var HTTPSession = util.NewHTTPSession()
var ShortExtractor = &models.Extractor{
Name: "Reddit (Short)",
@ -44,7 +37,7 @@ var ShortExtractor = &models.Extractor{
req.AddCookie(cookie)
}
res, err := HTTPClient.Do(req)
res, err := HTTPSession.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
@ -236,7 +229,7 @@ func GetRedditData(host string, slug string) (RedditResponse, error) {
req.AddCookie(cookie)
}
res, err := HTTPClient.Do(req)
res, err := HTTPSession.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}