commit body length

This commit is contained in:
liujian
2021-12-01 18:01:57 +08:00
parent f70169d4bd
commit 8e79bba086
2 changed files with 9 additions and 3 deletions

View File

@@ -25,12 +25,18 @@ func NewResponse(ctx *fasthttp.RequestCtx) *Response {
return &Response{Response: &ctx.Response, ResponseHeader: NewResponseHeader(&ctx.Response.Header)}
}
func (r *Response) BodyLen() int {
return r.header.Len()
}
func (r *Response) GetBody() []byte {
if strings.Contains(r.GetHeader("Content-Encoding"), "gzip") {
body, _ := r.BodyGunzip()
r.Headers().Del("Content-Encoding")
r.SetHeader("Content-Length", strconv.Itoa(len(body)))
r.Response.SetBody(body)
}
return r.Response.Body()
}