Compare commits

..

4 Commits

Author SHA1 Message Date
Thomas Boerger 67694d2750 Merge pull request #4 from drone-plugins/stats-code
Properly check for status 200
2018-05-02 13:01:37 +02:00
Thomas Boerger ccc30ebd8d Merge pull request #5 from drone-plugins/redirect-basicauth
Add basic auth on redirects
2018-05-02 13:01:27 +02:00
Thomas Boerger 49372d3e9d Add basic auth on redirects 2018-05-02 12:25:36 +02:00
Thomas Boerger e12b6abe00 Properly check for status 200 2018-05-02 11:53:44 +02:00
+11
View File
@@ -57,6 +57,13 @@ func (p Plugin) Exec() error {
InsecureSkipVerify: p.Config.SkipVerify,
},
},
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if p.Config.Username != "" && p.Config.Password != "" {
req.SetBasicAuth(p.Config.Username, p.Config.Password)
}
return nil
},
}
req, err := http.NewRequest(
@@ -81,6 +88,10 @@ func (p Plugin) Exec() error {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return errors.Errorf("request failed, status %s", http.StatusText(resp.StatusCode))
}
target, err := os.Create(destination)
if err != nil {