Skip to content

Commit

Permalink
Cleanup proxy code and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ahobsonsayers committed Sep 23, 2024
1 parent 94e1e9c commit 887aa71
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/testutils/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,25 @@ func (t *proxyTransport) RoundTrip(request *http.Request) (*http.Response, error
func downloadProxyLists(proxyListUrls []string) ([]*url.URL, error) {
proxyUrls := []*url.URL{}
for _, proxyListUrl := range proxyListUrls {
resp, err := http.Get(proxyListUrl)
proxyListProxyUrls, err := downloadProxyList(proxyListUrl)
if err != nil {
return nil, err
}
defer resp.Body.Close()

proxyListProxyUrls, err := parseProxyList(resp.Body)
if err != nil {
return nil, err
}

proxyUrls = append(proxyUrls, proxyListProxyUrls...)
}

return proxyUrls, nil
}

func downloadProxyList(proxyListUrl string) ([]*url.URL, error) {
resp, err := http.Get(proxyListUrl)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return parseProxyList(resp.Body)
}

func parseProxyList(reader io.Reader) ([]*url.URL, error) {
var proxyUrls []*url.URL
scanner := bufio.NewScanner(reader)
Expand Down

0 comments on commit 887aa71

Please sign in to comment.