mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 03:27:23 -05:00 
			
		
		
		
	reverseproxy: Set Content-Length when body is fully buffered (#6638)
This commit is contained in:
		
							parent
							
								
									e76405d550
								
							
						
					
					
						commit
						c864b82ae1
					
				@ -639,7 +639,8 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
 | 
				
			|||||||
	if h.RequestBuffers != 0 && req.Body != nil {
 | 
						if h.RequestBuffers != 0 && req.Body != nil {
 | 
				
			||||||
		var readBytes int64
 | 
							var readBytes int64
 | 
				
			||||||
		req.Body, readBytes = h.bufferedBody(req.Body, h.RequestBuffers)
 | 
							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.ContentLength = readBytes
 | 
				
			||||||
			req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
 | 
								req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user