修复在HTTP/2中反向代理出现的411错误

This commit is contained in:
刘祥超
2021-04-19 19:28:18 +08:00
parent bce8fd5ea3
commit 6d0f90747e

View File

@@ -147,6 +147,12 @@ func (this *HTTPRequest) doReverseProxy() {
return
}
// 在HTTP/2下需要防止因为requestBody而导致Content-Length为空的问题
if this.RawReq.ProtoMajor == 2 && this.RawReq.ContentLength == 0 {
_ = this.RawReq.Body.Close()
this.RawReq.Body = nil
}
// 开始请求
resp, err := client.Do(this.RawReq)
if err != nil {