update response getbody method

This commit is contained in:
liujian
2021-12-01 17:49:12 +08:00
parent f2ea5fa5c9
commit f70169d4bd

View File

@@ -2,6 +2,7 @@ package http_context
import (
"strconv"
"strings"
http_service "github.com/eolinker/eosc/http-service"
@@ -25,6 +26,11 @@ func NewResponse(ctx *fasthttp.RequestCtx) *Response {
}
func (r *Response) GetBody() []byte {
if strings.Contains(r.GetHeader("Content-Encoding"), "gzip") {
body, _ := r.BodyGunzip()
r.Headers().Del("Content-Encoding")
r.Response.SetBody(body)
}
return r.Response.Body()
}