Skip to content

Commit

Permalink
Merge pull request #80 from mikaelpeltier/Fix-Fetch-User-Info
Browse files Browse the repository at this point in the history
Add User-Agent to http request to avoid request error in some cases.
  • Loading branch information
showwin authored Nov 14, 2022
2 parents 66933e1 + 014e6b4 commit 1f33fd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions speedtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (client *Speedtest) FetchServerListContext(ctx context.Context, user *User)
return Servers{}, err
}

req.Header.Set("User-Agent", "Go-http-client/1.1") // Request could be rejected if not initialized

resp, err := client.doer.Do(req)
if err != nil {
return Servers{}, err
Expand All @@ -103,6 +105,8 @@ func (client *Speedtest) FetchServerListContext(ctx context.Context, user *User)
return Servers{}, err
}

req.Header.Set("User-Agent", "Go-http-client/1.1") // Request could be rejected if not initialized

resp, err = client.doer.Do(req)
if err != nil {
return Servers{}, err
Expand Down
2 changes: 2 additions & 0 deletions speedtest/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func (client *Speedtest) FetchUserInfoContext(ctx context.Context) (*User, error
return nil, err
}

req.Header.Set("User-Agent", "Go-http-client/1.1") // Request could be rejected if not initialized

resp, err := client.doer.Do(req)
if err != nil {
return nil, err
Expand Down

0 comments on commit 1f33fd0

Please sign in to comment.