Skip to content

Commit

Permalink
proxy: fix TestReverseProxy failure on go tip (caddyserver#1360)
Browse files Browse the repository at this point in the history
Because of this commit(6e36811) 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 caddyserver#1359

Signed-off-by: Tw <[email protected]>
  • Loading branch information
tw4452852 authored and mholt committed Jan 18, 2017
1 parent 6bac558 commit ecf852e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion caddyhttp/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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, "-")

Expand Down

0 comments on commit ecf852e

Please sign in to comment.