aboutsummaryrefslogtreecommitdiff
path: root/header_test.go
diff options
context:
space:
mode:
authorGravatar kinggo <lilong.21@bytedance.com> 2022-10-22 18:04:46 +0800
committerGravatar GitHub <noreply@github.com> 2022-10-22 12:04:46 +0200
commit128e9b35c48610a2c23c5ed56a8a2c413fd43609 (patch)
treed588da5c85585ec495579f2069317c41f59bec38 /header_test.go
parentfeat: add header.PeekAll (#1394) (diff)
downloadfasthttp-128e9b35c48610a2c23c5ed56a8a2c413fd43609.tar.gz
fasthttp-128e9b35c48610a2c23c5ed56a8a2c413fd43609.tar.bz2
fasthttp-128e9b35c48610a2c23c5ed56a8a2c413fd43609.zip
optimize: adjust the behavior of PeekAll based on VisitAll (#1403)v1.41.0
Diffstat (limited to 'header_test.go')
-rw-r--r--header_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/header_test.go b/header_test.go
index 643e8f3..fdefc3c 100644
--- a/header_test.go
+++ b/header_test.go
@@ -2883,6 +2883,13 @@ func TestRequestHeader_PeekAll(t *testing.T) {
expectRequestHeaderAll(t, h, "Cookie", [][]byte{s2b("foobar=baz")})
expectRequestHeaderAll(t, h, HeaderTrailer, [][]byte{s2b("Foo, Bar")})
expectRequestHeaderAll(t, h, "aaa", [][]byte{s2b("aaa"), s2b("bbb")})
+
+ h.Del("Content-Type")
+ h.Del(HeaderHost)
+ h.Del("aaa")
+ expectRequestHeaderAll(t, h, "Content-Type", [][]byte{})
+ expectRequestHeaderAll(t, h, HeaderHost, [][]byte{})
+ expectRequestHeaderAll(t, h, "aaa", [][]byte{})
}
func expectRequestHeaderAll(t *testing.T, h *RequestHeader, key string, expectedValue [][]byte) {
if len(h.PeekAll(key)) != len(expectedValue) {
@@ -2913,6 +2920,11 @@ func TestResponseHeader_PeekAll(t *testing.T) {
expectResponseHeaderAll(t, h, HeaderServer, [][]byte{s2b("aaaa")})
expectResponseHeaderAll(t, h, HeaderSetCookie, [][]byte{s2b("cccc")})
expectResponseHeaderAll(t, h, "aaa", [][]byte{s2b("aaa"), s2b("bbb")})
+
+ h.Del(HeaderContentType)
+ h.Del(HeaderContentEncoding)
+ expectResponseHeaderAll(t, h, HeaderContentType, [][]byte{defaultContentType})
+ expectResponseHeaderAll(t, h, HeaderContentEncoding, [][]byte{})
}
func expectResponseHeaderAll(t *testing.T, h *ResponseHeader, key string, expectedValue [][]byte) {