Skip to content

Commit f768afa

Browse files
authored
Merge pull request #1 from c-holtermann/http-download-check
check for http.statusOK 200 when downloading
2 parents b8d433c + 486475d commit f768afa

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bridge/helper/helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func DownloadFileAuth(url string, auth string) (*[]byte, error) {
4343
return nil, err
4444
}
4545
defer resp.Body.Close()
46+
if resp.StatusCode != http.StatusOK {
47+
peek, _ := io.ReadAll(resp.Body)
48+
return nil, fmt.Errorf("unexpected HTTP status: %s, body: %.100s", resp.Status, peek)
49+
}
4650
io.Copy(&buf, resp.Body)
4751
data := buf.Bytes()
4852
return &data, nil

0 commit comments

Comments
 (0)