Skip to content

Commit

Permalink
fix: tolerate tests that do not specify any headers (#438)
Browse files Browse the repository at this point in the history
Fixes #437
  • Loading branch information
theseion authored Jan 3, 2025
1 parent 7806472 commit a40d380
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 1 addition & 4 deletions ftwhttp/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ func (h Header) WriteBytes(b *bytes.Buffer) (int, error) {
return count, nil
}

// Clone returns a copy of h or nil if h is nil.
// Clone returns a copy of h
func (h Header) Clone() Header {
if h == nil {
return nil
}
clone := make(Header)

for n, v := range h {
Expand Down
14 changes: 14 additions & 0 deletions ftwhttp/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,17 @@ func (s *requestTestSuite) TestRequestEncodesPostData() {
})
}
}

func (s *requestTestSuite) TestNewRequest_EmptyHeaders() {
rl := &RequestLine{
Method: "POST",
URI: "/path",
Version: "1.1",
}

req := NewRequest(rl, nil, []byte{}, false)

headers := req.Headers()
s.NotNil(headers)
s.Empty(headers)
}

0 comments on commit a40d380

Please sign in to comment.