fix: pre-read bodies with unknown length

This commit is contained in:
MiMoCode
2026-07-10 19:36:49 +08:00
parent f27382c33a
commit 32988b6367
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ import (
// readRequestBody 在转发前完整读取请求体,确保读取失败时不会向上游发送损坏请求。
func readRequestBody(r *http.Request, max int64) (captured []byte, truncated bool, err error) {
if r.Body == nil || r.ContentLength == 0 {
if r.Body == nil || r.Body == http.NoBody {
return nil, false, nil
}
body, err := io.ReadAll(r.Body)