From 34000962ef8f26acd831ab43dbb42f2f521f9866 Mon Sep 17 00:00:00 2001 From: Bagas Date: Sat, 18 Jul 2026 15:29:01 +0700 Subject: [PATCH] fix(httphandler): use readSlice for reading http header --- internal/transport/httphandler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/transport/httphandler.go b/internal/transport/httphandler.go index d9b627b..795b83a 100644 --- a/internal/transport/httphandler.go +++ b/internal/transport/httphandler.go @@ -56,8 +56,14 @@ func (hh *httpHandler) badRequest(conn net.Conn) error { func readHTTPHeader(br *bufio.Reader, limit int) ([]byte, error) { var headerBuf []byte for { - line, err := br.ReadBytes('\n') + line, err := br.ReadSlice('\n') headerBuf = append(headerBuf, line...) + if errors.Is(err, bufio.ErrBufferFull) { + if len(headerBuf) > limit { + return nil, fmt.Errorf("headers too large") + } + continue + } if err != nil { return nil, err }