-
Notifications
You must be signed in to change notification settings - Fork 328
Open
Labels
Description
Hi guys,
I found that oxy/buffer can't handle response with chunked encoding and empty body. I can reproduce it by adding the testcase below:
func TestEmptyChunkedResponse(t *testing.T) {
srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
h := w.(http.Hijacker)
conn, _, _ := h.Hijack()
_, _ = fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n")
_ = conn.Close()
})
t.Cleanup(srv.Close)
fwd := forward.New(false)
rdr := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
req.URL = testutils.ParseURI(srv.URL)
fwd.ServeHTTP(w, req)
})
st, err := New(rdr)
require.NoError(t, err)
proxy := httptest.NewServer(st)
t.Cleanup(proxy.Close)
re, body, err := testutils.Get(proxy.URL)
require.NoError(t, err)
assert.Equal(t, "", string(body))
assert.Equal(t, http.StatusOK, re.StatusCode)
}I have test proxys like nginx and traefik with curl, they all looks fine. But if i use oxy/buffer, it will return 500 Internal Server Error
ErikMichelson and gionn