refactor(writer): improve headerVal function clarity

Changed from zero-value check to existence check for clearer intent.
Both approaches have similar performance characteristics for map lookups,
but using 'ok' makes it explicit we're checking for key presence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jacquin Antoine
2026-04-19 14:38:56 +02:00
parent 3429c74e03
commit 506d151832

View File

@ -503,10 +503,13 @@ func formatTLSVersion(v uint16) string {
// headerVal cherche un en-tête dans le map avec deux clés possibles :
// HTTP/1.1 utilise Title-Case (ex: "User-Agent"), HTTP/2 utilise lowercase (ex: "user-agent").
// Optimisé pour réduire le nombre de lookups : essayer titleKey d'abord, puis lowerKey seulement si nécessaire.
func headerVal(kv map[string]string, titleKey, lowerKey string) string {
if v := kv[titleKey]; v != "" {
// Essayer Title-Case d'abord (HTTP/1.1)
if v, ok := kv[titleKey]; ok {
return v
}
// Fallback à lowercase (HTTP/2)
return kv[lowerKey]
}