diff --git a/header.go b/header.go index 4eb199b34f..068ee15be3 100644 --- a/header.go +++ b/header.go @@ -3011,12 +3011,20 @@ func (h *ResponseHeader) parseHeaders(buf []byte) (int, error) { return 0, fmt.Errorf("invalid header key %q", s.key) } + spaceIncluded := false for _, ch := range s.key { if !validHeaderFieldByte(ch) { + if ch == ' ' { + spaceIncluded = true + break + } h.connectionClose = true return 0, fmt.Errorf("invalid header key %q", s.key) } } + if spaceIncluded { + continue + } for _, ch := range s.value { if !validHeaderValueByte(ch) { h.connectionClose = true