Skip to content

Commit

Permalink
reverseproxy: Set Content-Length when body is fully buffered (#6638)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng authored Dec 17, 2024
1 parent e76405d commit c864b82
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/caddyhttp/reverseproxy/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
if h.RequestBuffers != 0 && req.Body != nil {
var readBytes int64
req.Body, readBytes = h.bufferedBody(req.Body, h.RequestBuffers)
if h.RequestBuffers == -1 {
// set Content-Length when body is fully buffered
if b, ok := req.Body.(bodyReadCloser); ok && b.body == nil {
req.ContentLength = readBytes
req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
}
Expand Down

0 comments on commit c864b82

Please sign in to comment.