Merge pull request #1856 from versity/sis/error-response-content-type

fix: adds application/xml Content-Type to error responses
This commit is contained in:
Ben McClelland
2026-02-16 12:53:26 -08:00
committed by GitHub
2 changed files with 12 additions and 0 deletions
+9
View File
@@ -148,6 +148,8 @@ func WrapMiddleware(handler fiber.Handler, logger s3log.AuditLogger, mm metrics.
})
}
ctx.Response().Header.SetContentType(fiber.MIMEApplicationXML)
serr, ok := err.(s3err.APIError)
if ok {
ctx.Status(serr.HTTPStatusCode)
@@ -197,6 +199,10 @@ func ProcessController(ctx *fiber.Ctx, controller Controller, s3action string, s
ObjectSize: opts.ObjectSize,
})
}
// set content type to application/xml
ctx.Response().Header.SetContentType(fiber.MIMEApplicationXML)
serr, ok := err.(s3err.APIError)
if ok {
ctx.Status(serr.HTTPStatusCode)
@@ -295,6 +301,9 @@ func ProcessController(ctx *fiber.Ctx, controller Controller, s3action string, s
}
ctx.Status(http.StatusInternalServerError)
// set content type to application/xml
ctx.Response().Header.SetContentType(fiber.MIMEApplicationXML)
return ctx.Send(s3err.GetAPIErrorResponse(
s3err.GetAPIError(s3err.ErrInternalError), "", "", ""))
}
+3
View File
@@ -197,6 +197,9 @@ func stackTraceHandler(ctx *fiber.Ctx, e any) {
// globalErrorHandler catches the errors before reaching to
// the handlers and any system panics
func globalErrorHandler(ctx *fiber.Ctx, er error) error {
// set content type to application/xml
ctx.Response().Header.SetContentType(fiber.MIMEApplicationXML)
if utils.ContextKeyStack.IsSet(ctx) {
// if stack is set, it means the stack trace
// has caught a panic