diff --git a/internal/logger/target/http/http.go b/internal/logger/target/http/http.go index 6084ae025..b8bb28b9c 100644 --- a/internal/logger/target/http/http.go +++ b/internal/logger/target/http/http.go @@ -98,7 +98,7 @@ func (h *Target) Init() error { // Drain any response. xhttp.DrainBody(resp.Body) - if resp.StatusCode != http.StatusOK { + if !acceptedResponseStatusCode(resp.StatusCode) { switch resp.StatusCode { case http.StatusForbidden: return fmt.Errorf("%s returned '%s', please check if your auth token is correctly set", @@ -112,6 +112,13 @@ func (h *Target) Init() error { return nil } +// Accepted HTTP Status Codes +var acceptedStatusCodeMap = map[int]bool{http.StatusOK: true, http.StatusCreated: true, http.StatusAccepted: true, http.StatusNoContent: true} + +func acceptedResponseStatusCode(code int) bool { + return acceptedStatusCodeMap[code] +} + func (h *Target) startHTTPLogger() { // Create a routine which sends json logs received // from an internal channel.