diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2020-11-02 22:22:01 +0100 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2020-11-02 22:22:01 +0100 |
commit | ce7b94fee9a8fd0fbb7996a63367b8237e9863c7 (patch) | |
tree | f71d4e7631e4869c55ee6abeb73e541c831b8076 /http_test.go | |
parent | Ignore *.fasthttp.br files from tests (diff) | |
download | fasthttp-ce7b94fee9a8fd0fbb7996a63367b8237e9863c7.tar.gz fasthttp-ce7b94fee9a8fd0fbb7996a63367b8237e9863c7.tar.bz2 fasthttp-ce7b94fee9a8fd0fbb7996a63367b8237e9863c7.zip |
Add Request.SetBodyRaw
Fixes https://github.com/valyala/fasthttp/issues/891
Diffstat (limited to 'http_test.go')
-rw-r--r-- | http_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/http_test.go b/http_test.go index bcac9dc..c67f520 100644 --- a/http_test.go +++ b/http_test.go @@ -2081,6 +2081,18 @@ func TestResponseRawBodySet(t *testing.T) { testBodyWriteTo(t, &resp, expectedS, true) } +func TestRequestRawBodySet(t *testing.T) { + t.Parallel() + + var r Request + + expectedS := "test" + body := []byte(expectedS) + r.SetBodyRaw(body) + + testBodyWriteTo(t, &r, expectedS, true) +} + func TestResponseRawBodyReset(t *testing.T) { t.Parallel() @@ -2093,6 +2105,18 @@ func TestResponseRawBodyReset(t *testing.T) { testBodyWriteTo(t, &resp, "", true) } +func TestRequestRawBodyReset(t *testing.T) { + t.Parallel() + + var r Request + + body := []byte("test") + r.SetBodyRaw(body) + r.ResetBody() + + testBodyWriteTo(t, &r, "", true) +} + func TestResponseRawBodyCopyTo(t *testing.T) { t.Parallel() @@ -2105,6 +2129,22 @@ func TestResponseRawBodyCopyTo(t *testing.T) { testResponseCopyTo(t, &resp) } +func TestRequestRawBodyCopyTo(t *testing.T) { + t.Parallel() + + var a Request + + body := []byte("test") + a.SetBodyRaw(body) + + var b Request + + a.CopyTo(&b) + + testBodyWriteTo(t, &a, "test", true) + testBodyWriteTo(t, &b, "test", true) +} + type testReader struct { read chan (int) cb chan (struct{}) |