-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Recorded body overwritten by error status code handler #1531
Comments
Hello, actually that was a feature rather than a bug, there is a test case for that as well: iris/core/router/status_test.go Lines 38 to 43 in 02699ed
The same thing happens to a gzip response writer as well, the code: Lines 445 to 454 in 02699ed
Why?
That's why the Note: you can use the package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
app.Post("/fail", func(ctx iris.Context) {
ctx.Record()
ctx.StatusCode(iris.StatusInternalServerError) // 500 status code
ctx.WriteString("My error message")
// ctx.Next() // also you don't need that.
})
app.Listen(":8080")
} UpdateOK. The default behavior is now changed to respect any body and headers set on recorder and gzip writer on error codes. The behavior is now aligned with the common response writer as you correctly noted it should. However, it brings a breaking change which can be fixed by the new Thank you @feliciegodineau |
When the request is being recorded, the body is overwritten before sending the response by the error status code handler. This doesn't happen when the request is not recorded.
Response:
Internal Server Error
This can be hotfix by setting the option
DisableAutoFireStatusCode
totrue
But, I think that the request should have the same behaviour when it's being recorded and when it's not.
Response:
My error message
The text was updated successfully, but these errors were encountered: