Skip to content

Commit

Permalink
Merge pull request #1461 from cloudflare/ensure-get-ips-is-200
Browse files Browse the repository at this point in the history
ips: handle non-200 responses
  • Loading branch information
jacobbednarz authored Dec 13, 2023
2 parents fd17f69 + 44feda7 commit cf73155
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ips.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloudflare

import (
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -41,6 +42,9 @@ func IPs() (IPRanges, error) {
if err != nil {
return IPRanges{}, fmt.Errorf("HTTP request failed: %w", err)
}
if resp.StatusCode != http.StatusOK {
return IPRanges{}, errors.New("HTTP request failed: status is not HTTP 200")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down

0 comments on commit cf73155

Please sign in to comment.