mirror of
https://github.com/versity/versitygw.git
synced 2026-08-17 12:46:23 +00:00
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:
@@ -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), "", "", ""))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user