aboutsummaryrefslogtreecommitdiff
path: root/header_test.go
diff options
context:
space:
mode:
authorGravatar Anthony Ter-Saakov <58586369+antter@users.noreply.github.com> 2023-06-12 12:49:52 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-12 21:49:52 +0200
commitb79233fac2991fee200d15f761c3cc65b99abc7d (patch)
treef0db58a310e18ca2650e0451ca46b6d8271f67ea /header_test.go
parentfs: fix race condition on global map (#1565) (diff)
downloadfasthttp-b79233fac2991fee200d15f761c3cc65b99abc7d.tar.gz
fasthttp-b79233fac2991fee200d15f761c3cc65b99abc7d.tar.bz2
fasthttp-b79233fac2991fee200d15f761c3cc65b99abc7d.zip
add DisableSpecialHeaders option (#1573)
* add DisableSpecialHeaders option * polishing up disableSpecialHeader option * forgot to uncomment * fix silly mistakes * dont parse special headers
Diffstat (limited to 'header_test.go')
-rw-r--r--header_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/header_test.go b/header_test.go
index 94eee8b..f53959e 100644
--- a/header_test.go
+++ b/header_test.go
@@ -348,6 +348,35 @@ func TestRequestRawHeaders(t *testing.T) {
})
}
+func TestRequestDisableSpecialHeaders(t *testing.T) {
+ t.Parallel()
+
+ kvs := "Host: foobar\r\n" +
+ "User-Agent: ua\r\n" +
+ "Non-Special: val\r\n" +
+ "\r\n"
+
+ var h RequestHeader
+ h.DisableSpecialHeader()
+
+ s := "GET / HTTP/1.0\r\n" + kvs
+ br := bufio.NewReader(bytes.NewBufferString(s))
+ if err := h.Read(br); err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ // assert order of all headers preserved
+ if h.String() != s {
+ t.Fatalf("Headers not equal: %q. Expecting %q", h.String(), s)
+ }
+ h.SetCanonical([]byte("host"), []byte("notfoobar"))
+ if string(h.Host()) != "foobar" {
+ t.Fatalf("unexpected: %q. Expecting %q", h.Host(), "foobar")
+ }
+ if h.String() != "GET / HTTP/1.0\r\nHost: foobar\r\nUser-Agent: ua\r\nNon-Special: val\r\nhost: notfoobar\r\n\r\n" {
+ t.Fatalf("custom special header ordering failed: %q", h.String())
+ }
+}
+
func TestRequestHeaderSetCookieWithSpecialChars(t *testing.T) {
t.Parallel()