mirror of
https://github.com/eolinker/apinto
synced 2025-11-01 04:22:40 +08:00
commit body length
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user