Skip to content

Commit

Permalink
Fix user-agent on fetching server list JSON
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
maddie committed Jun 29, 2020
1 parent 1f8dc72 commit 166771b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions speedtest/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func SpeedTest(c *cli.Context) error {

if err != nil {
log.Info("Retry with /.well-known/librespeed")
servers, err = getServerList(c.Bool(defs.OptionSecure), serverUrl + "/.well-known/librespeed", c.IntSlice(defs.OptionExclude), c.IntSlice(defs.OptionServer), !c.Bool(defs.OptionList))
servers, err = getServerList(c.Bool(defs.OptionSecure), serverUrl+"/.well-known/librespeed", c.IntSlice(defs.OptionExclude), c.IntSlice(defs.OptionServer), !c.Bool(defs.OptionList))
}
}
if err != nil {
Expand Down Expand Up @@ -347,7 +347,13 @@ func getServerList(forceHTTPS bool, serverList string, excludes, specific []int,

// getting the server list from remote
var servers []defs.Server
resp, err := http.DefaultClient.Get(serverList)
req, err := http.NewRequest(http.MethodGet, serverList, nil)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", defs.UserAgent)

resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 166771b

Please sign in to comment.