如果源站返回的内容长度为0,则不再尝试读取数据

This commit is contained in:
刘祥超
2022-01-03 18:10:02 +08:00
parent 258ffef0c2
commit d62fccf0a4
2 changed files with 8 additions and 2 deletions

View File

@@ -293,6 +293,13 @@ func (this *HTTPRequest) doReverseProxy() {
this.writer.WriteHeader(resp.StatusCode)
}
// 是否有内容
if resp.ContentLength == 0 && len(resp.TransferEncoding) == 0 {
_ = resp.Body.Close()
this.writer.SetOk()
return
}
// 输出到客户端
pool := this.bytePool(resp.ContentLength)
buf := pool.Get()