Skip to content

Commit

Permalink
Merge pull request #31 from ooni/merged-stable
Browse files Browse the repository at this point in the history
Merge go1.18.5 into the stable v0.2.x train

Part of ooni/probe#2223
  • Loading branch information
bassosimone authored Aug 22, 2022
2 parents fbeda16 + f080d96 commit 624798f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func (h Header) Clone() Header {
sv := make([]string, nv) // shared backing array for headers' values
h2 := make(Header, len(h))
for k, vv := range h {
if vv == nil {
// Preserve nil values. ReverseProxy distinguishes
// between nil and zero-length header values.
h2[k] = nil
continue
}
n := copy(sv, vv)
h2[k] = sv[:n:n]
sv = sv[n:]
Expand Down
5 changes: 5 additions & 0 deletions header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ func TestCloneOrMakeHeader(t *testing.T) {
in: Header{"foo": {"bar"}},
want: Header{"foo": {"bar"}},
},
{
name: "nil value",
in: Header{"foo": nil},
want: Header{"foo": nil},
},
}

for _, tt := range tests {
Expand Down
1 change: 1 addition & 0 deletions serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6148,6 +6148,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
"fugazi",
"foo-bar",
"unknown",
"\rchunked",
}

for _, badTE := range unsupportedTEs {
Expand Down
2 changes: 1 addition & 1 deletion transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func (t *transferReader) parseTransferEncoding() error {
if len(raw) != 1 {
return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)}
}
if !ascii.EqualFold(textproto.TrimString(raw[0]), "chunked") {
if !ascii.EqualFold(raw[0], "chunked") {
return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", raw[0])}
}

Expand Down

0 comments on commit 624798f

Please sign in to comment.