diff options
author | Abe Saiovici <abe.saiovici@gmail.com> | 2023-04-12 16:51:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 22:51:30 +0200 |
commit | d76662b46dcfcd2040331d6b215daa5c9be038b9 (patch) | |
tree | dc11ac6cc081504512e63349b6e80a42d3a45c8c /http_test.go | |
parent | support response body stream (#1414) (diff) | |
download | fasthttp-d76662b46dcfcd2040331d6b215daa5c9be038b9.tar.gz fasthttp-d76662b46dcfcd2040331d6b215daa5c9be038b9.tar.bz2 fasthttp-d76662b46dcfcd2040331d6b215daa5c9be038b9.zip |
Fixed transfer-encoding for empty chunked payload (#1536)
Diffstat (limited to 'http_test.go')
-rw-r--r-- | http_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/http_test.go b/http_test.go index 32194a8..42feb56 100644 --- a/http_test.go +++ b/http_test.go @@ -2011,6 +2011,25 @@ func TestRequestReadChunked(t *testing.T) { verifyTrailer(t, rb, map[string]string{"Trail": "test"}, true) } +func TestRequestChunkedEmpty(t *testing.T) { + t.Parallel() + + var req Request + + s := "POST /foo HTTP/1.1\r\nHost: google.com\r\nTransfer-Encoding: chunked\r\nContent-Type: aa/bb\r\n\r\n0\r\n\r\n" + r := bytes.NewBufferString(s) + rb := bufio.NewReader(r) + err := req.Read(rb) + if err != nil { + t.Fatalf("Unexpected error when reading chunked request: %v", err) + } + expectedBody := "" + if string(req.Body()) != expectedBody { + t.Fatalf("Unexpected body %q. Expected %q", req.Body(), expectedBody) + } + expectRequestHeaderGet(t, &req.Header, HeaderTransferEncoding, "") +} + // See: https://github.com/erikdubbelboer/fasthttp/issues/34 func TestRequestChunkedWhitespace(t *testing.T) { t.Parallel() |