Skip to content

Commit

Permalink
fix: 🐛 修复 gzip 压缩响应异常
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed May 5, 2023
1 parent 484bfda commit 085251a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion common/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,19 @@ func modifyGzipBody(res *http.Response, originalScheme string, originalHost stri
if err != nil {
return err
}
err = writer.Flush()
if err != nil {
return err
}
err = writer.Close()
if err != nil {
return err
}

// 修改 Content-Length 头
res.Header.Set("Content-Length", strconv.Itoa(buf.Len()))
// 修改响应内容
res.Body = io.NopCloser(bytes.NewReader(buf.Bytes()))
res.Body = io.NopCloser(&buf)

return nil
}
Expand Down

0 comments on commit 085251a

Please sign in to comment.