Skip to content

Commit

Permalink
net/http2: omit invalid header value from error message
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderYastrebov committed Oct 14, 2021
1 parent 2b766c0 commit 90d4a60
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion http2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (e headerFieldNameError) Error() string {
type headerFieldValueError string

func (e headerFieldValueError) Error() string {
return fmt.Sprintf("invalid header field value %q", string(e))
return fmt.Sprintf("invalid header field value for %q", string(e))
}

var (
Expand Down
2 changes: 1 addition & 1 deletion http2/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) {
fr.debugReadLoggerf("http2: decoded hpack field %+v", hf)
}
if !httpguts.ValidHeaderFieldValue(hf.Value) {
invalid = headerFieldValueError(hf.Value)
invalid = headerFieldValueError(hf.Name)
}
isPseudo := strings.HasPrefix(hf.Name, ":")
if isPseudo {
Expand Down
2 changes: 1 addition & 1 deletion http2/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ func TestTransportInvalidTrailer_EmptyFieldName(t *testing.T) {
})
}
func TestTransportInvalidTrailer_BinaryFieldValue(t *testing.T) {
testInvalidTrailer(t, oneHeader, headerFieldValueError("has\nnewline"), func(enc *hpack.Encoder) {
testInvalidTrailer(t, oneHeader, headerFieldValueError("x"), func(enc *hpack.Encoder) {
enc.WriteField(hpack.HeaderField{Name: "x", Value: "has\nnewline"})
})
}
Expand Down

0 comments on commit 90d4a60

Please sign in to comment.