Skip to content

Commit c864b82

Browse files
authored
reverseproxy: Set Content-Length when body is fully buffered (#6638)
1 parent e76405d commit c864b82

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/caddyhttp/reverseproxy/reverseproxy.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
639639
if h.RequestBuffers != 0 && req.Body != nil {
640640
var readBytes int64
641641
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 {
643644
req.ContentLength = readBytes
644645
req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
645646
}

0 commit comments

Comments
 (0)