@marcel91200 / caddy Mirror · read-only / commits / c864b82a
Fork 0

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, 04:30 UTC

reverseproxy: Set Content-Length when body is fully buffered (#6638)

WeidiDeng committed Dec 18, 2024 at 07:36 UTC c864b82ae13f9dc920ebd8782fe7c5b7007a3e1b
1 file changed +2 -1
modules/caddyhttp/reverseproxy/reverseproxy.go
+2 -1
@@ -639,7 +639,8 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
639 if h.RequestBuffers != 0 && req.Body != nil {
640 var readBytes int64
641 req.Body, readBytes = h.bufferedBody(req.Body, h.RequestBuffers)
642 - if h.RequestBuffers == -1 {
642 + // set Content-Length when body is fully buffered
643 + if b, ok := req.Body.(bodyReadCloser); ok && b.body == nil {
644 req.ContentLength = readBytes
645 req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
646 }