Skip to content

Commit

Permalink
Allow redirects from http to https on the same host, fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
rverton committed Sep 29, 2020
1 parent 6b5bcaa commit 19890c3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions webanalyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func NewWebAnalyzer(apps io.Reader, client *http.Client) (*WebAnalyzer, error) {
return nil, err
}


wa.client = client

return wa, nil
Expand Down Expand Up @@ -108,7 +107,17 @@ func fetchHost(host string, client *http.Client) (*http.Response, error) {
Proxy: http.ProxyFromEnvironment,
},
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
url, err := url.Parse(host)
if err != nil {
return http.ErrUseLastResponse
}

// allow redirects from http -> https on the same host
if url.Host != via[len(via)-1].URL.Host {
return http.ErrUseLastResponse
}

return nil
},
}
}
Expand Down

0 comments on commit 19890c3

Please sign in to comment.