Set a custom user-agent header when fetching CTC Cambridge stops data
This is required because their hosting provider is returning a 503 "service unavailable" when the user agent is Go-http-client.
This commit is contained in:
parent
4ef3eca5a4
commit
f09fd9a418
1 changed files with 6 additions and 1 deletions
|
@ -54,7 +54,12 @@ func BuildCtcCamIndex(r io.Reader) (*rtreego.Rtree, error) {
|
||||||
|
|
||||||
func FetchCtcCamIndex() (*rtreego.Rtree, error) {
|
func FetchCtcCamIndex() (*rtreego.Rtree, error) {
|
||||||
log.Printf("Fetching %s", ctcCamWaypointsUrl)
|
log.Printf("Fetching %s", ctcCamWaypointsUrl)
|
||||||
res, err := http.Get(ctcCamWaypointsUrl)
|
req, err := http.NewRequest(http.MethodGet, ctcCamWaypointsUrl, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error constructing waypoints request: %v", err)
|
||||||
|
}
|
||||||
|
req.Header.Set("User-Agent", "gpx-utils")
|
||||||
|
res, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting %s: %v", ctcCamWaypointsUrl, err)
|
return nil, fmt.Errorf("error getting %s: %v", ctcCamWaypointsUrl, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue