1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00
This commit is contained in:
Gerasimos Maropoulos
2016-08-14 05:44:36 +03:00
parent 56bd511427
commit c6f5406c3b
7 changed files with 160 additions and 117 deletions

View File

@@ -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)
}