Skip to content

Commit

Permalink
Merge ae1d003 into d21a04a
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoranz758 committed Sep 18, 2023
2 parents d21a04a + ae1d003 commit 1253389
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/protocol/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,12 @@ func (h *RequestHeader) DelBytes(key []byte) {
h.del(h.bufKV.key)
}

// Del deletes header with the given key.
func (h *RequestHeader) Del(key string) {
k := getHeaderKeyBytes(&h.bufKV, key, h.disableNormalizing)
h.del(k)
}

func (h *RequestHeader) SetArgBytes(key, value []byte, noValue bool) {
h.h = setArgBytes(h.h, key, value, noValue)
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/protocol/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func TestRequestHeaderDel(t *testing.T) {
var h RequestHeader
h.Set("Foo-Bar", "baz")
h.Set("aaa", "bbb")
h.Set("ccc", "ddd")
h.Set(consts.HeaderConnection, "keep-alive")
h.Set(consts.HeaderContentType, "aaa")
h.Set(consts.HeaderServer, "aaabbb")
Expand All @@ -226,11 +227,16 @@ func TestRequestHeaderDel(t *testing.T) {
h.del([]byte("Host"))
h.del([]byte(consts.HeaderTrailer))
h.DelCookie("foo")
h.Del("ccc")

hv := h.Peek("aaa")
if string(hv) != "bbb" {
t.Fatalf("unexpected header value: %q. Expecting %q", hv, "bbb")
}
hv = h.Peek("ccc")
if string(hv) != "" {
t.Fatalf("unexpected header value: %q. Expecting %q", hv, "")
}
hv = h.Peek("Foo-Bar")
if len(hv) > 0 {
t.Fatalf("non-zero header value: %q", hv)
Expand Down

0 comments on commit 1253389

Please sign in to comment.