diff options
author | WeidiDeng <[email protected]> | 2024-10-17 09:09:26 +0800 |
---|---|---|
committer | WeidiDeng <[email protected]> | 2024-10-17 09:09:26 +0800 |
commit | 8c11e51747ab834f5a5b581fcdb403ee9449cf23 (patch) | |
tree | 3d3e0d6ab8ff30d49d86ecd9b49158d5be0bd7b6 | |
parent | c6f2979986d87d7236b132c687c8887c92248dd8 (diff) | |
download | caddy-8c11e51747ab834f5a5b581fcdb403ee9449cf23.tar.gz caddy-8c11e51747ab834f5a5b581fcdb403ee9449cf23.zip |
set content-length when body is fully bufferedbuffer-content-length
-rw-r--r-- | modules/caddyhttp/reverseproxy/reverseproxy.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index 123bf774b..c81368813 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -625,7 +625,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)) } |