mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 10:26:29 +02:00
httputil: ignore errors < 400 (#3781)
This commit is contained in:
parent
090601873f
commit
a5082f60e7
2 changed files with 9 additions and 6 deletions
|
@ -69,12 +69,14 @@ func (e *HTTPError) ErrorResponse(ctx context.Context, w http.ResponseWriter, r
|
|||
// indicate to clients that the error originates from Pomerium, not the app
|
||||
w.Header().Set(HeaderPomeriumResponse, "true")
|
||||
|
||||
log.Error(ctx).
|
||||
Err(e.Err).
|
||||
Int("status", e.Status).
|
||||
Str("status-text", StatusText(e.Status)).
|
||||
Str("request-id", reqID).
|
||||
Msg("httputil: error")
|
||||
if e.Status >= 400 {
|
||||
log.Error(ctx).
|
||||
Err(e.Err).
|
||||
Int("status", e.Status).
|
||||
Str("status-text", StatusText(e.Status)).
|
||||
Str("request-id", reqID).
|
||||
Msg("httputil: error")
|
||||
}
|
||||
|
||||
if r.Header.Get("Accept") == "application/json" {
|
||||
RenderJSON(w, e.Status, response)
|
||||
|
|
|
@ -21,6 +21,7 @@ func TestHTTPError_ErrorResponse(t *testing.T) {
|
|||
}{
|
||||
{"404 json", http.StatusNotFound, errors.New("route not known"), "application/json", http.StatusNotFound, "{\"Status\":404}\n"},
|
||||
{"404 html", http.StatusNotFound, errors.New("route not known"), "", http.StatusNotFound, ""},
|
||||
{"302 found", http.StatusFound, errors.New("redirect"), "", http.StatusFound, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue