Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
0add1c3e
Commit
0add1c3e
authored
Apr 29, 2011
by
Evan Shaw
Committed by
Brad Fitzpatrick
Apr 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http/cgi: correctly set request Content-Type
R=bradfitz CC=golang-dev
https://golang.org/cl/4433087
parent
da9b8b83
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
child.go
src/pkg/http/cgi/child.go
+4
-0
child_test.go
src/pkg/http/cgi/child_test.go
+4
-0
No files found.
src/pkg/http/cgi/child.go
View file @
0add1c3e
...
...
@@ -84,6 +84,10 @@ func RequestFromMap(params map[string]string) (*http.Request, os.Error) {
r
.
ContentLength
=
clen
}
if
ct
:=
params
[
"CONTENT_TYPE"
];
ct
!=
""
{
r
.
Header
.
Set
(
"Content-Type"
,
ct
)
}
// Copy "HTTP_FOO_BAR" variables to "Foo-Bar" Headers
for
k
,
v
:=
range
params
{
if
!
strings
.
HasPrefix
(
k
,
"HTTP_"
)
||
skipHeader
[
k
]
{
...
...
src/pkg/http/cgi/child_test.go
View file @
0add1c3e
...
...
@@ -20,6 +20,7 @@ func TestRequest(t *testing.T) {
"HTTP_FOO_BAR"
:
"baz"
,
"REQUEST_URI"
:
"/path?a=b"
,
"CONTENT_LENGTH"
:
"123"
,
"CONTENT_TYPE"
:
"text/xml"
,
"HTTPS"
:
"1"
,
"REMOTE_ADDR"
:
"5.6.7.8"
,
}
...
...
@@ -37,6 +38,9 @@ func TestRequest(t *testing.T) {
// Tests that we don't put recognized headers in the map
t
.
Errorf
(
"expected User-Agent %q; got %q"
,
e
,
g
)
}
if
g
,
e
:=
req
.
Header
.
Get
(
"Content-Type"
),
"text/xml"
;
e
!=
g
{
t
.
Errorf
(
"expected Content-Type %q; got %q"
,
e
,
g
)
}
if
g
,
e
:=
req
.
ContentLength
,
int64
(
123
);
e
!=
g
{
t
.
Errorf
(
"expected ContentLength %d; got %d"
,
e
,
g
)
}
...
...
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