diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-12-03 11:58:15 -0500 |
---|---|---|
committer | Michael Anthony Knyszek <mknyszek@google.com> | 2021-12-03 11:58:15 -0500 |
commit | c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589 (patch) | |
tree | f0543c1806db096c0ab766a14f05d2725e6c0791 /src/net/http/clientserver_test.go | |
parent | 06a4b2790c5bb6530e0c4f05277b19c187134f49 (diff) | |
parent | 8faefcbfce6d2b2875ab74d81bb4e94b2e3adaf5 (diff) | |
download | go-c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589.tar.gz go-c884bd9ef2f1f36a98fa89bb4be07d4f9fe66589.zip |
[dev.boringcrypto.go1.16] all: merge go1.16.11 into dev.boringcrypto.go1.16
Change-Id: I38f5b727d23d22238bf6886a7e33b5f72edeaa38
Diffstat (limited to 'src/net/http/clientserver_test.go')
-rw-r--r-- | src/net/http/clientserver_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go index 5e227181ac..125d63566b 100644 --- a/src/net/http/clientserver_test.go +++ b/src/net/http/clientserver_test.go @@ -1582,3 +1582,37 @@ func TestH12_WebSocketUpgrade(t *testing.T) { }, }.run(t) } + +func TestIdentityTransferEncoding_h1(t *testing.T) { testIdentityTransferEncoding(t, h1Mode) } +func TestIdentityTransferEncoding_h2(t *testing.T) { testIdentityTransferEncoding(t, h2Mode) } + +func testIdentityTransferEncoding(t *testing.T, h2 bool) { + setParallel(t) + defer afterTest(t) + + const body = "body" + cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) { + gotBody, _ := io.ReadAll(r.Body) + if got, want := string(gotBody), body; got != want { + t.Errorf("got request body = %q; want %q", got, want) + } + w.Header().Set("Transfer-Encoding", "identity") + w.WriteHeader(StatusOK) + w.(Flusher).Flush() + io.WriteString(w, body) + })) + defer cst.close() + req, _ := NewRequest("GET", cst.ts.URL, strings.NewReader(body)) + res, err := cst.c.Do(req) + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + gotBody, err := io.ReadAll(res.Body) + if err != nil { + t.Fatal(err) + } + if got, want := string(gotBody), body; got != want { + t.Errorf("got response body = %q; want %q", got, want) + } +} |