We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db4efeb commit 491a49aCopy full SHA for 491a49a
http2/server.go
@@ -719,7 +719,15 @@ func (sc *serverConn) canonicalHeader(v string) string {
719
sc.canonHeader = make(map[string]string)
720
}
721
cv = http.CanonicalHeaderKey(v)
722
- sc.canonHeader[v] = cv
+ // maxCachedCanonicalHeaders is an arbitrarily-chosen limit on the number of
723
+ // entries in the canonHeader cache. This should be larger than the number
724
+ // of unique, uncommon header keys likely to be sent by the peer, while not
725
+ // so high as to permit unreaasonable memory usage if the peer sends an unbounded
726
+ // number of unique header keys.
727
+ const maxCachedCanonicalHeaders = 32
728
+ if len(sc.canonHeader) < maxCachedCanonicalHeaders {
729
+ sc.canonHeader[v] = cv
730
+ }
731
return cv
732
733
0 commit comments