From cdf19f840191ccad7a353e3ffcf46776fa3950b7 Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Mon, 16 Apr 2018 10:48:46 -0700 Subject: [PATCH] Add test case where request is send as a chunked-encoded request --- examples/integration_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/integration_test.go b/examples/integration_test.go index 405726258fc..5cc2ed70e50 100644 --- a/examples/integration_test.go +++ b/examples/integration_test.go @@ -15,6 +15,7 @@ import ( "time" "context" + "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/empty" @@ -667,6 +668,20 @@ func testAdditionalBindings(t *testing.T, port int) { } return resp }, + func() *http.Response { + r, w := io.Pipe() + go func() { + defer w.Close() + w.Write([]byte(`"hello"`)) + }() + url := fmt.Sprintf("http://localhost:%d/v2/example/echo", port) + resp, err := http.Post(url, "application/json", r) + if err != nil { + t.Errorf("http.Post(%q, %q, %q) failed with %v; want success", url, "application/json", `"hello"`, err) + return nil + } + return resp + }, func() *http.Response { url := fmt.Sprintf("http://localhost:%d/v2/example/echo?value=hello", port) resp, err := http.Get(url)