Skip to content

Commit

Permalink
Do not try to follow redirects in MVT responses
Browse files Browse the repository at this point in the history
Mapillary server sometimes returns 301 redirect to login page which
seems to be a misconfiguration of the service.
  • Loading branch information
wladich committed Aug 28, 2022
1 parent 7e55234 commit ee66235
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,19 @@ func renderFromMvt(mvtData *[]byte, tileSize uint32, dataScale uint32, offsetX f
func downloadData(url string) ([]byte, error) {
const timeout = 15 * time.Second

client := http.Client{Timeout: timeout}
client := http.Client{
Timeout: timeout,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
resp, err := client.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("HTTP error %d for %s", resp.StatusCode, url)
return nil, fmt.Errorf("HTTP status %d for %s", resp.StatusCode, url)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down

0 comments on commit ee66235

Please # to comment.