mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
Better gzip managment, align with https://github.com/kataras/iris/issues/361 . OnError on Parties: https://github.com/kataras/iris/issues/35
This commit is contained in:
@@ -151,12 +151,13 @@ func (r *responseEngineMap) render(ctx *Context, obj interface{}, options ...map
|
||||
}
|
||||
ctx.SetContentType(ctype)
|
||||
|
||||
if gzipEnabled {
|
||||
if gzipEnabled && ctx.clientAllowsGzip() {
|
||||
_, err := fasthttp.WriteGzip(ctx.RequestCtx.Response.BodyWriter(), finalResult)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.Response.Header.Add("Content-Encoding", "gzip")
|
||||
ctx.RequestCtx.Response.Header.Add(varyHeader, acceptEncodingHeader)
|
||||
ctx.SetHeader(contentEncodingHeader, "gzip")
|
||||
} else {
|
||||
ctx.Response.SetBody(finalResult)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user