From d9e202001b792064a35cf2b8b7caba4efb25a1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 6 Aug 2021 20:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9F=BA=E7=A1=80=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=95=B0=E6=8D=AE=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/forward.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/proxy/forward.go b/proxy/forward.go index b7273d1..af2334d 100644 --- a/proxy/forward.go +++ b/proxy/forward.go @@ -8,6 +8,7 @@ package proxy import ( + "bytes" "compress/gzip" "fmt" "io" @@ -15,8 +16,6 @@ import ( "net" "net/http" "strings" - - "git.zhangdeman.cn/zhangdeman/gopkg/safe" ) // Forward 正向代理的实现 @@ -61,6 +60,9 @@ func Forward(rw http.ResponseWriter, req *http.Request, serverConfig *Server) { // step 3 for key, value := range res.Header { for _, v := range value { + if strings.ToLower(key) == "content-encoding" { + continue + } rw.Header().Add(key, v) } } @@ -81,9 +83,9 @@ func Forward(rw http.ResponseWriter, req *http.Request, serverConfig *Server) { gzipData, err = gzip.NewReader(res.Body) responseData, err = ioutil.ReadAll(gzipData) fmt.Println(string(responseData), err) - formatData, _ := safe.Filter(responseData, serverConfig.RewriteResponseData) - rw.Write(formatData) - } + bytesBuffer := bytes.NewReader([]byte(`{"data":{"permission":true}}`)) + io.Copy(rw, bytesBuffer) + } res.Body.Close() }