From 1c9a91e28ee4e44946d9021cf757d38b1ab46df2 Mon Sep 17 00:00:00 2001 From: prepaser Date: Fri, 13 Dec 2024 19:49:11 +0900 Subject: [PATCH] fix: ignoring response header field space --- header.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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