修复内容为空时无法缓存的Bug

This commit is contained in:
GoEdgeLab
2022-06-09 20:26:36 +08:00
parent fb5029bad1
commit 366d0d74b1
3 changed files with 9 additions and 2 deletions

View File

@@ -328,7 +328,12 @@ func (this *HTTPRequest) doReverseProxy() {
// 是否有内容
if resp.ContentLength == 0 && len(resp.TransferEncoding) == 0 {
// 即使内容为0也需要读取一次以便于触发相关事件
var buf = utils.BytePool4k.Get()
_, _ = io.CopyBuffer(this.writer, resp.Body, buf)
utils.BytePool4k.Put(buf)
_ = resp.Body.Close()
this.writer.SetOk()
return
}