Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the length of trailer key should > 0 #1410

Merged
merged 1 commit into from Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion header.go
Expand Up @@ -2520,8 +2520,8 @@ func (h *ResponseHeader) parseTrailer(buf []byte) (int, error) {
err = fmt.Errorf("forbidden trailer key %q", s.key)
continue
}
h.h = appendArgBytes(h.h, s.key, s.value, argsHasValue)
}
h.h = appendArgBytes(h.h, s.key, s.value, argsHasValue)
}
if s.err != nil {
return 0, s.err
Expand Down
8 changes: 4 additions & 4 deletions http_test.go
Expand Up @@ -1641,10 +1641,10 @@ func TestRequestReadLimitBody(t *testing.T) {
}

func testResponseReadLimitBodyError(t *testing.T, s string, maxBodySize int, expectedErr error) {
var req Response
var resp Response
r := bytes.NewBufferString(s)
br := bufio.NewReader(r)
err := req.ReadLimitBody(br, maxBodySize)
err := resp.ReadLimitBody(br, maxBodySize)
if err == nil {
t.Fatalf("expecting error. s=%q, maxBodySize=%d", s, maxBodySize)
}
Expand All @@ -1654,10 +1654,10 @@ func testResponseReadLimitBodyError(t *testing.T, s string, maxBodySize int, exp
}

func testResponseReadLimitBodySuccess(t *testing.T, s string, maxBodySize int) {
var req Response
var resp Response
r := bytes.NewBufferString(s)
br := bufio.NewReader(r)
if err := req.ReadLimitBody(br, maxBodySize); err != nil {
if err := resp.ReadLimitBody(br, maxBodySize); err != nil {
t.Fatalf("unexpected error: %v. s=%q, maxBodySize=%d", err, s, maxBodySize)
}
}
Expand Down