blob: 149b3dd20e45f64cc47c98f46fb96ebdac7d277d [file] [log] [blame]
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http2
import (
var (
commonBuildOnce sync.Once
commonLowerHeader map[string]string // Go-Canonical-Case -> lower-case
commonCanonHeader map[string]string // lower-case -> Go-Canonical-Case
func buildCommonHeaderMapsOnce() {
func buildCommonHeaderMaps() {
common := []string{
commonLowerHeader = make(map[string]string, len(common))
commonCanonHeader = make(map[string]string, len(common))
for _, v := range common {
chk := http.CanonicalHeaderKey(v)
commonLowerHeader[chk] = v
commonCanonHeader[v] = chk
func lowerHeader(v string) (lower string, ascii bool) {
if s, ok := commonLowerHeader[v]; ok {
return s, true
return asciiToLower(v)
func canonicalHeader(v string) string {
if s, ok := commonCanonHeader[v]; ok {
return s
return http.CanonicalHeaderKey(v)