Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
f7a71c65
Commit
f7a71c65
authored
Sep 08, 2010
by
Jukka-Pekka Kekkonen
Committed by
Russ Cox
Sep 08, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: do not cache CanonicalHeaderKey
Fixes #1080. R=rsc CC=golang-dev
https://golang.org/cl/2158043
parent
5baaa490
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
src/pkg/http/request.go
src/pkg/http/request.go
+13
-11
No files found.
src/pkg/http/request.go
View file @
f7a71c65
...
...
@@ -382,29 +382,30 @@ func parseHTTPVersion(vers string) (int, int, bool) {
return
major
,
minor
,
true
}
var
cmap
=
make
(
map
[
string
]
string
)
// CanonicalHeaderKey returns the canonical format of the
// HTTP header key s. The canonicalization converts the first
// letter and any letter following a hyphen to upper case;
// the rest are converted to lowercase. For example, the
// canonical key for "accept-encoding" is "Accept-Encoding".
func
CanonicalHeaderKey
(
s
string
)
string
{
if
t
,
ok
:=
cmap
[
s
];
ok
{
return
t
}
// canonicalize: first letter upper case
// and upper case after each dash.
// (Host, User-Agent, If-Modified-Since).
// HTTP headers are ASCII only, so no Unicode issues.
a
:=
[]
byte
(
s
)
var
a
[]
byte
upper
:=
true
for
i
,
v
:=
range
a
{
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
v
:=
s
[
i
]
if
upper
&&
'a'
<=
v
&&
v
<=
'z'
{
if
a
==
nil
{
a
=
[]
byte
(
s
)
}
a
[
i
]
=
v
+
'A'
-
'a'
}
if
!
upper
&&
'A'
<=
v
&&
v
<=
'Z'
{
if
a
==
nil
{
a
=
[]
byte
(
s
)
}
a
[
i
]
=
v
+
'a'
-
'A'
}
upper
=
false
...
...
@@ -412,9 +413,10 @@ func CanonicalHeaderKey(s string) string {
upper
=
true
}
}
t
:=
string
(
a
)
cmap
[
s
]
=
t
return
t
if
a
!=
nil
{
return
string
(
a
)
}
return
s
}
type
chunkedReader
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment