mirror of https://github.com/minio/minio.git
all 2xx status codes to be success for audit (#20394)
This commit is contained in:
parent
64e803b136
commit
0f1e8db4c5
|
@ -21,7 +21,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.22.5
|
||||
go-version: 1.22.7
|
||||
- name: Get official govulncheck
|
||||
run: go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
shell: bash
|
||||
|
|
|
@ -196,13 +196,15 @@ func (target *WebhookTarget) send(eventData event.Event) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer xhttp.DrainBody(resp.Body)
|
||||
xhttp.DrainBody(resp.Body)
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||
return fmt.Errorf("sending event failed with %v", resp.Status)
|
||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||
// accepted HTTP status codes.
|
||||
return nil
|
||||
} else if resp.StatusCode == http.StatusForbidden {
|
||||
return fmt.Errorf("%s returned '%s', please check if your auth token is correctly set", target.args.Endpoint, resp.Status)
|
||||
}
|
||||
|
||||
return nil
|
||||
return fmt.Errorf("%s returned '%s', please check your endpoint configuration", target.args.Endpoint, resp.Status)
|
||||
}
|
||||
|
||||
// SendFromStore - reads an event from store and sends it to webhook.
|
||||
|
|
|
@ -266,15 +266,13 @@ func (h *Target) send(ctx context.Context, payload []byte, payloadCount int, pay
|
|||
// Drain any response.
|
||||
xhttp.DrainBody(resp.Body)
|
||||
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent:
|
||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||
// accepted HTTP status codes.
|
||||
return nil
|
||||
case http.StatusForbidden:
|
||||
} else if resp.StatusCode == http.StatusForbidden {
|
||||
return fmt.Errorf("%s returned '%s', please check if your auth token is correctly set", h.Endpoint(), resp.Status)
|
||||
default:
|
||||
return fmt.Errorf("%s returned '%s', please check your endpoint configuration", h.Endpoint(), resp.Status)
|
||||
}
|
||||
return fmt.Errorf("%s returned '%s', please check your endpoint configuration", h.Endpoint(), resp.Status)
|
||||
}
|
||||
|
||||
func (h *Target) startQueueProcessor(ctx context.Context, mainWorker bool) {
|
||||
|
|
Loading…
Reference in New Issue