Skip to content

Commit bd362a9

Browse files
committed
Use HTTP status code constants rather than numerical literals
Signed-off-by: beorn7 <[email protected]>
1 parent f24de70 commit bd362a9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

prometheus/push/push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (p *Pusher) Delete() error {
220220
return err
221221
}
222222
defer resp.Body.Close()
223-
if resp.StatusCode != 202 {
223+
if resp.StatusCode != http.StatusAccepted {
224224
body, _ := ioutil.ReadAll(resp.Body) // Ignore any further error as this is for an error message only.
225225
return fmt.Errorf("unexpected status code %d while deleting %s: %s", resp.StatusCode, p.fullURL(), body)
226226
}
@@ -267,7 +267,8 @@ func (p *Pusher) push(method string) error {
267267
return err
268268
}
269269
defer resp.Body.Close()
270-
if resp.StatusCode != 200 && resp.StatusCode != 202 {
270+
// Pushgateway 0.10+ responds with StatusOK, earlier versions with StatusAccepted.
271+
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
271272
body, _ := ioutil.ReadAll(resp.Body) // Ignore any further error as this is for an error message only.
272273
return fmt.Errorf("unexpected status code %d while pushing to %s: %s", resp.StatusCode, p.fullURL(), body)
273274
}

0 commit comments

Comments
 (0)