From 848c44b130b796f51f399e425db0559de4e2d5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Thu, 8 Nov 2018 19:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=BF=E6=8D=A2=E8=B7=A8?= =?UTF-8?q?=E7=AB=99=E7=82=B9url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/http.go b/http.go index d05448b..4288b8a 100755 --- a/http.go +++ b/http.go @@ -69,6 +69,7 @@ func EncodeResponse(r *http.Response) ([]byte, error) { raw := bytes.NewBuffer([]byte{}) binary.Write(raw, binary.LittleEndian, []byte("sign")) respBytes, err := httputil.DumpResponse(r, true) + respBytes = replaceHost(respBytes) if err != nil { return nil, err } @@ -97,3 +98,12 @@ func getHost(str string) (string, error) { } return "", errors.New("没有找到解析的的host!") } + +func replaceHost(resp []byte) []byte { + str := string(resp) + for _, v := range config.SiteList { + str = strings.Replace(str, v.Url+":"+string(v.Port), v.Host, -1) + str = strings.Replace(str, v.Url, v.Host, -1) + } + return []byte(str) +}