File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -719,7 +719,15 @@ func (sc *serverConn) canonicalHeader(v string) string {
719
719
sc .canonHeader = make (map [string ]string )
720
720
}
721
721
cv = http .CanonicalHeaderKey (v )
722
- sc .canonHeader [v ] = cv
722
+ // 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
+ }
723
731
return cv
724
732
}
725
733
You can’t perform that action at this time.
0 commit comments