Commit Graph

1 Commits

Author SHA1 Message Date
Thibault Jamet aa6002134e
Fix intercepting headers in middlewares (#1271)
* Fix intercepting headers in middlewares

As explained in the TestInterceptedHeader test, in case a middleware
filters out the headers, this middleware can be done inefficient in case
one following handler is using c.String or other methods writing to the
response body directly.

This commit fixes the issue by using c.Writer when writing the Status as
done in other c.Header, c.SetCookie and other response writers.

The bug has been originally discovered using
https://github.com/gin-contrib/gzip where a failing test has been added
here: https://github.com/tjamet/gzip/blob/header/gzip_test.go#L71

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>

* Skip Intercepted Header test for go <1.6

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
2022-05-28 08:27:10 +08:00