From ecf852ea43db136da5513da76f5f95bddd6aab04 Mon Sep 17 00:00:00 2001 From: Tw Date: Thu, 19 Jan 2017 06:34:25 +0800 Subject: [PATCH] proxy: fix TestReverseProxy failure on go tip (#1360) Because of this commit(6e36811c37399d60cbce587b7c48e611009c5aec) on go tip, it will probe the request's body to determine whether to use chunked transfer encoding which trailers depend on it. So we just offer a non empty body to make trailers work. fix issue #1359 Signed-off-by: Tw --- caddyhttp/proxy/proxy_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/caddyhttp/proxy/proxy_test.go b/caddyhttp/proxy/proxy_test.go index 7ffdb775..97957695 100644 --- a/caddyhttp/proxy/proxy_test.go +++ b/caddyhttp/proxy/proxy_test.go @@ -78,7 +78,7 @@ func TestReverseProxy(t *testing.T) { } // create request and response recorder - r := httptest.NewRequest("GET", "/", nil) + r := httptest.NewRequest("GET", "/", strings.NewReader("test")) w := httptest.NewRecorder() r.ContentLength = -1 // force chunked encoding (required for trailers) @@ -97,6 +97,7 @@ func TestReverseProxy(t *testing.T) { verifyHeaders(res.Header, res.Trailer) // Make sure {upstream} placeholder is set + r.Body = ioutil.NopCloser(strings.NewReader("test")) rr := httpserver.NewResponseRecorder(httptest.NewRecorder()) rr.Replacer = httpserver.NewReplacer(r, rr, "-")