Commit ecf852ea authored by Tw's avatar Tw Committed by Matt Holt

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: default avatarTw <tw19881113@gmail.com>
parent 6bac558c
...@@ -78,7 +78,7 @@ func TestReverseProxy(t *testing.T) { ...@@ -78,7 +78,7 @@ func TestReverseProxy(t *testing.T) {
} }
// create request and response recorder // create request and response recorder
r := httptest.NewRequest("GET", "/", nil) r := httptest.NewRequest("GET", "/", strings.NewReader("test"))
w := httptest.NewRecorder() w := httptest.NewRecorder()
r.ContentLength = -1 // force chunked encoding (required for trailers) r.ContentLength = -1 // force chunked encoding (required for trailers)
...@@ -97,6 +97,7 @@ func TestReverseProxy(t *testing.T) { ...@@ -97,6 +97,7 @@ func TestReverseProxy(t *testing.T) {
verifyHeaders(res.Header, res.Trailer) verifyHeaders(res.Header, res.Trailer)
// Make sure {upstream} placeholder is set // Make sure {upstream} placeholder is set
r.Body = ioutil.NopCloser(strings.NewReader("test"))
rr := httpserver.NewResponseRecorder(httptest.NewRecorder()) rr := httpserver.NewResponseRecorder(httptest.NewRecorder())
rr.Replacer = httpserver.NewReplacer(r, rr, "-") rr.Replacer = httpserver.NewReplacer(r, rr, "-")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment