Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: go

go:
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
Expand Down
10 changes: 10 additions & 0 deletions forward/fwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ func (f *httpForwarder) serveHTTP(w http.ResponseWriter, inReq *http.Request, ct
} else {
revproxy.ServeHTTP(w, outReq)
}

for key := range w.Header() {
if strings.HasPrefix(key, http.TrailerPrefix) {
if fl, ok := w.(http.Flusher); ok {
fl.Flush()
}
break
}
}

}

// IsWebsocketRequest determines if the specified HTTP request is a
Expand Down
23 changes: 23 additions & 0 deletions forward/fwd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package forward
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -409,3 +410,25 @@ func TestTeTrailer(t *testing.T) {
assert.Equal(t, http.StatusOK, re.StatusCode)
assert.Equal(t, "trailers", teHeader)
}

func TestUnannouncedTrailer(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(200)
rw.(http.Flusher).Flush()

rw.Header().Add(http.TrailerPrefix+"X-Trailer", "foo")
}))

proxy, err := New()
require.Nil(t, err)

proxySrv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
req.URL = testutils.ParseURI(srv.URL)
proxy.ServeHTTP(rw, req)
}))

resp, _ := http.Get(proxySrv.URL)
ioutil.ReadAll(resp.Body)

require.Equal(t, resp.Trailer.Get("X-Trailer"), "foo")
}