diff options
author | MoreFreeze <morefreeze@users.noreply.github.com> | 2021-05-14 16:08:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-14 10:08:51 +0200 |
commit | 097fa05a697fc638624a14ab294f1336da9c29b0 (patch) | |
tree | b082d6ffd4140fa63b474e8035b5100669b1aaf6 /http_test.go | |
parent | Fix(adaptor): Fixed an issue where the adapter did not convert all (#1021) (diff) | |
download | fasthttp-097fa05a697fc638624a14ab294f1336da9c29b0.tar.gz fasthttp-097fa05a697fc638624a14ab294f1336da9c29b0.tar.bz2 fasthttp-097fa05a697fc638624a14ab294f1336da9c29b0.zip |
Fix ignoreBody still set content length (#1022)
* Fix ignore body should not set content-length
* Add TestRequestReadNoBody
Co-authored-by: liuchenxing <liuchenxing@bytedance.com>
Diffstat (limited to 'http_test.go')
-rw-r--r-- | http_test.go | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/http_test.go b/http_test.go index b6ac168..b2f487b 100644 --- a/http_test.go +++ b/http_test.go @@ -741,6 +741,23 @@ func TestResponseReadEOF(t *testing.T) { } } +func TestRequestReadNoBody(t *testing.T) { + t.Parallel() + + var r Request + + br := bufio.NewReader(bytes.NewBufferString("GET / HTTP/1.1\r\n\r\n")) + err := r.Read(br) + r.SetHost("foobar") + if err != nil { + t.Fatalf("unexpected error: %s", err) + } + s := r.String() + if strings.Contains(s, "Content-Length: ") { + t.Fatalf("unexpected Content-Length") + } +} + func TestResponseWriteTo(t *testing.T) { t.Parallel() @@ -2210,9 +2227,9 @@ func TestRequestRawBodyCopyTo(t *testing.T) { } type testReader struct { - read chan (int) - cb chan (struct{}) - onClose func() error + read chan (int) + cb chan (struct{}) + onClose func() error } func (r *testReader) Read(b []byte) (int, error) { |