1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-30 08:17:18 +00:00
This commit is contained in:
Gerasimos Maropoulos
2016-07-25 14:45:12 +03:00
parent 3ee38a363c
commit d10273391a
4 changed files with 19 additions and 15 deletions

View File

@@ -462,12 +462,10 @@ func (ctx *Context) Write(format string, a ...interface{}) {
// Gzip accepts bytes, which are compressed to gzip format and sent to the client
func (ctx *Context) Gzip(b []byte, status int) {
ctx.RequestCtx.Response.Header.Add("Content-Encoding", "gzip")
gzipWriter := ctx.framework.gzipWriterPool.Get().(*gzip.Writer)
gzipWriter.Reset(ctx.RequestCtx.Response.BodyWriter())
gzipWriter.Write(b)
gzipWriter.Close()
ctx.framework.gzipWriterPool.Put(gzipWriter)
_, err := fasthttp.WriteGzip(ctx.RequestCtx.Response.BodyWriter(), b)
if err == nil {
ctx.RequestCtx.Response.Header.Add("Content-Encoding", "gzip")
}
}
// RenderWithStatus builds up the response from the specified template or a response engine.