refactor(http2): 使用 textproto.CanonicalMIMEHeaderKey 替代手动实现

使用标准库 net/textproto 提供的规范化函数,确保 HTTP 头键
按照 RFC 7230 规范正确处理,包括 MIME 头的特殊大小写规则。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
xfy 2026-04-09 13:35:29 +08:00
parent 392d0b3449
commit 909bccc1eb

View File

@ -22,7 +22,7 @@ import (
"io"
"net"
"net/http"
"strings"
"net/textproto"
"sync"
"time"
@ -577,10 +577,5 @@ func (p *connectionPool) closeAll() { //nolint:unused // reserved for future use
// canonicalHeaderKey 返回规范化的 HTTP 头键。
func canonicalHeaderKey(key string) string {
// 使用 strings 包实现规范化
result := strings.ToLower(key)
if result == "" {
return ""
}
return strings.ToUpper(result[:1]) + result[1:]
return textproto.CanonicalMIMEHeaderKey(key)
}