Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 19:30 UTC
reverseproxy: Only change Content-Length when full request is buffered (#5830)
fixes: https://github.com/caddyserver/caddy/issues/5829 Signed-off-by: Fred Cox <mcfedr@gmail.com>
Fred Cox committed
Jan 9, 2024 at 19:59 UTC
d9ff7b18726e21327b21b5e30b0ebd90f9023b39
1 file changed
+6
-2
modules/caddyhttp/reverseproxy/reverseproxy.go
+6
-2
@@ -589,8 +589,12 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
589
// feature if absolutely required, if read timeouts are
590
// set, and if body size is limited
591
if h.RequestBuffers != 0 && req.Body != nil {
592
- req.Body, req.ContentLength = h.bufferedBody(req.Body, h.RequestBuffers)
593
- req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
592
+ var readBytes int64
593
+ req.Body, readBytes = h.bufferedBody(req.Body, h.RequestBuffers)
594
+ if h.RequestBuffers == -1 {
595
+ req.ContentLength = readBytes
596
+ req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
597
+ }
598
}
599
600
if req.ContentLength == 0 {