From a1dd6f0b348367a93cd61ff2cf3654dbbb8e2743 Mon Sep 17 00:00:00 2001 From: Tw Date: Mon, 24 Oct 2016 11:10:12 +0800 Subject: [PATCH] proxy: set request's body to nil explicitly fix issue #1206 Signed-off-by: Tw --- caddyhttp/proxy/proxy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/caddyhttp/proxy/proxy.go b/caddyhttp/proxy/proxy.go index fc2d727fa..a46ea71a6 100644 --- a/caddyhttp/proxy/proxy.go +++ b/caddyhttp/proxy/proxy.go @@ -218,6 +218,11 @@ func (p Proxy) match(r *http.Request) Upstream { func createUpstreamRequest(r *http.Request) *http.Request { outreq := new(http.Request) *outreq = *r // includes shallow copies of maps, but okay + // We should set body to nil explicitly if request body is empty. + // For server requests the Request Body is always non-nil. + if r.ContentLength == 0 { + outreq.Body = nil + } // Restore URL Path if it has been modified if outreq.URL.RawPath != "" {