mirror of
https://github.com/eolinker/apinto
synced 2025-11-01 04:22:40 +08:00
修复gzip压缩的问题
This commit is contained in:
@@ -46,7 +46,7 @@ func (r *Response) BodyLen() int {
|
||||
func (r *Response) GetBody() []byte {
|
||||
if strings.Contains(r.GetHeader("Content-Encoding"), "gzip") {
|
||||
body, _ := r.BodyGunzip()
|
||||
r.Headers().Del("Content-Encoding")
|
||||
r.DelHeader("Content-Encoding")
|
||||
r.SetHeader("Content-Length", strconv.Itoa(len(body)))
|
||||
r.Response.SetBody(body)
|
||||
}
|
||||
@@ -54,6 +54,15 @@ func (r *Response) GetBody() []byte {
|
||||
return r.Response.Body()
|
||||
}
|
||||
|
||||
func (r *Response) SetBody(bytes []byte) {
|
||||
if strings.Contains(r.GetHeader("Content-Encoding"), "gzip") {
|
||||
r.DelHeader("Content-Encoding")
|
||||
}
|
||||
r.Response.SetBody(bytes)
|
||||
r.SetHeader("Content-Length", strconv.Itoa(len(bytes)))
|
||||
r.responseError = nil
|
||||
}
|
||||
|
||||
func (r *Response) StatusCode() int {
|
||||
if r.responseError != nil {
|
||||
return 504
|
||||
@@ -82,9 +91,3 @@ func (r *Response) ProxyStatus() string {
|
||||
func (r *Response) SetProxyStatus(code int, status string) {
|
||||
r.proxyStatusCode = code
|
||||
}
|
||||
|
||||
func (r *Response) SetBody(bytes []byte) {
|
||||
r.Response.SetBody(bytes)
|
||||
r.SetHeader("Content-Length", strconv.Itoa(len(bytes)))
|
||||
r.responseError = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user