• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package http2
6
7import (
8	"net/http"
9	"strings"
10)
11
12var (
13	commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case
14	commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case
15)
16
17func init() {
18	for _, v := range []string{
19		"accept",
20		"accept-charset",
21		"accept-encoding",
22		"accept-language",
23		"accept-ranges",
24		"age",
25		"access-control-allow-origin",
26		"allow",
27		"authorization",
28		"cache-control",
29		"content-disposition",
30		"content-encoding",
31		"content-language",
32		"content-length",
33		"content-location",
34		"content-range",
35		"content-type",
36		"cookie",
37		"date",
38		"etag",
39		"expect",
40		"expires",
41		"from",
42		"host",
43		"if-match",
44		"if-modified-since",
45		"if-none-match",
46		"if-unmodified-since",
47		"last-modified",
48		"link",
49		"location",
50		"max-forwards",
51		"proxy-authenticate",
52		"proxy-authorization",
53		"range",
54		"referer",
55		"refresh",
56		"retry-after",
57		"server",
58		"set-cookie",
59		"strict-transport-security",
60		"trailer",
61		"transfer-encoding",
62		"user-agent",
63		"vary",
64		"via",
65		"www-authenticate",
66	} {
67		chk := http.CanonicalHeaderKey(v)
68		commonLowerHeader[chk] = v
69		commonCanonHeader[v] = chk
70	}
71}
72
73func lowerHeader(v string) string {
74	if s, ok := commonLowerHeader[v]; ok {
75		return s
76	}
77	return strings.ToLower(v)
78}
79