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
0db312b6
Commit
0db312b6
authored
Mar 07, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: use Header type consistently
R=bradfitzgo, dsymonds CC=golang-dev
https://golang.org/cl/4244053
parent
7fb65a93
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
17 deletions
+16
-17
client.go
src/pkg/http/client.go
+1
-1
readrequest_test.go
src/pkg/http/readrequest_test.go
+1
-1
request.go
src/pkg/http/request.go
+1
-1
requestwrite_test.go
src/pkg/http/requestwrite_test.go
+2
-2
response.go
src/pkg/http/response.go
+8
-9
responsewrite_test.go
src/pkg/http/responsewrite_test.go
+3
-3
No files found.
src/pkg/http/client.go
View file @
0db312b6
...
@@ -117,7 +117,7 @@ func send(req *Request, t Transport) (resp *Response, err os.Error) {
...
@@ -117,7 +117,7 @@ func send(req *Request, t Transport) (resp *Response, err os.Error) {
// Headers, leaving it uninitialized. We guarantee to the
// Headers, leaving it uninitialized. We guarantee to the
// Transport that this has been initialized, though.
// Transport that this has been initialized, though.
if
req
.
Header
==
nil
{
if
req
.
Header
==
nil
{
req
.
Header
=
Header
(
make
(
map
[
string
][]
string
)
)
req
.
Header
=
make
(
Header
)
}
}
info
:=
req
.
URL
.
RawUserinfo
info
:=
req
.
URL
.
RawUserinfo
...
...
src/pkg/http/readrequest_test.go
View file @
0db312b6
...
@@ -93,7 +93,7 @@ var reqTests = []reqTest{
...
@@ -93,7 +93,7 @@ var reqTests = []reqTest{
Proto
:
"HTTP/1.1"
,
Proto
:
"HTTP/1.1"
,
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
ProtoMinor
:
1
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
Close
:
false
,
Close
:
false
,
ContentLength
:
-
1
,
ContentLength
:
-
1
,
Host
:
"test"
,
Host
:
"test"
,
...
...
src/pkg/http/request.go
View file @
0db312b6
...
@@ -247,7 +247,7 @@ func (req *Request) write(w io.Writer, usingProxy bool) os.Error {
...
@@ -247,7 +247,7 @@ func (req *Request) write(w io.Writer, usingProxy bool) os.Error {
// from Request, and introduce Request methods along the lines of
// from Request, and introduce Request methods along the lines of
// Response.{GetHeader,AddHeader} and string constants for "Host",
// Response.{GetHeader,AddHeader} and string constants for "Host",
// "User-Agent" and "Referer".
// "User-Agent" and "Referer".
err
=
writeSorted
KeyValue
(
w
,
req
.
Header
,
reqExcludeHeader
)
err
=
writeSorted
Header
(
w
,
req
.
Header
,
reqExcludeHeader
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
src/pkg/http/requestwrite_test.go
View file @
0db312b6
...
@@ -84,7 +84,7 @@ var reqWriteTests = []reqWriteTest{
...
@@ -84,7 +84,7 @@ var reqWriteTests = []reqWriteTest{
},
},
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
ProtoMinor
:
1
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
TransferEncoding
:
[]
string
{
"chunked"
},
TransferEncoding
:
[]
string
{
"chunked"
},
},
},
...
@@ -112,7 +112,7 @@ var reqWriteTests = []reqWriteTest{
...
@@ -112,7 +112,7 @@ var reqWriteTests = []reqWriteTest{
},
},
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
ProtoMinor
:
1
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
Close
:
true
,
Close
:
true
,
TransferEncoding
:
[]
string
{
"chunked"
},
TransferEncoding
:
[]
string
{
"chunked"
},
},
},
...
...
src/pkg/http/response.go
View file @
0db312b6
...
@@ -67,10 +67,9 @@ type Response struct {
...
@@ -67,10 +67,9 @@ type Response struct {
// ReadResponse nor Response.Write ever closes a connection.
// ReadResponse nor Response.Write ever closes a connection.
Close
bool
Close
bool
// Trailer maps trailer keys to values. Like for Header, if the
// Trailer maps trailer keys to values, in the same
// response has multiple trailer lines with the same key, they will be
// format as the header.
// concatenated, delimited by commas.
Trailer
Header
Trailer
map
[
string
][]
string
}
}
// ReadResponse reads and returns an HTTP response from r. The RequestMethod
// ReadResponse reads and returns an HTTP response from r. The RequestMethod
...
@@ -193,7 +192,7 @@ func (resp *Response) Write(w io.Writer) os.Error {
...
@@ -193,7 +192,7 @@ func (resp *Response) Write(w io.Writer) os.Error {
}
}
// Rest of header
// Rest of header
err
=
writeSorted
KeyValue
(
w
,
resp
.
Header
,
respExcludeHeader
)
err
=
writeSorted
Header
(
w
,
resp
.
Header
,
respExcludeHeader
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -215,16 +214,16 @@ func (resp *Response) Write(w io.Writer) os.Error {
...
@@ -215,16 +214,16 @@ func (resp *Response) Write(w io.Writer) os.Error {
return
nil
return
nil
}
}
func
writeSorted
KeyValue
(
w
io
.
Writer
,
kvm
map
[
string
][]
string
,
exclude
map
[
string
]
bool
)
os
.
Error
{
func
writeSorted
Header
(
w
io
.
Writer
,
h
Header
,
exclude
map
[
string
]
bool
)
os
.
Error
{
keys
:=
make
([]
string
,
0
,
len
(
kvm
))
keys
:=
make
([]
string
,
0
,
len
(
h
))
for
k
:=
range
kvm
{
for
k
:=
range
h
{
if
!
exclude
[
k
]
{
if
!
exclude
[
k
]
{
keys
=
append
(
keys
,
k
)
keys
=
append
(
keys
,
k
)
}
}
}
}
sort
.
SortStrings
(
keys
)
sort
.
SortStrings
(
keys
)
for
_
,
k
:=
range
keys
{
for
_
,
k
:=
range
keys
{
for
_
,
v
:=
range
kvm
[
k
]
{
for
_
,
v
:=
range
h
[
k
]
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s: %s
\r\n
"
,
k
,
v
);
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s: %s
\r\n
"
,
k
,
v
);
err
!=
nil
{
return
err
return
err
}
}
...
...
src/pkg/http/responsewrite_test.go
View file @
0db312b6
...
@@ -22,7 +22,7 @@ var respWriteTests = []respWriteTest{
...
@@ -22,7 +22,7 @@ var respWriteTests = []respWriteTest{
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
0
,
ProtoMinor
:
0
,
RequestMethod
:
"GET"
,
RequestMethod
:
"GET"
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
ContentLength
:
6
,
ContentLength
:
6
,
},
},
...
@@ -38,7 +38,7 @@ var respWriteTests = []respWriteTest{
...
@@ -38,7 +38,7 @@ var respWriteTests = []respWriteTest{
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
0
,
ProtoMinor
:
0
,
RequestMethod
:
"GET"
,
RequestMethod
:
"GET"
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
ContentLength
:
-
1
,
ContentLength
:
-
1
,
},
},
...
@@ -53,7 +53,7 @@ var respWriteTests = []respWriteTest{
...
@@ -53,7 +53,7 @@ var respWriteTests = []respWriteTest{
ProtoMajor
:
1
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
ProtoMinor
:
1
,
RequestMethod
:
"GET"
,
RequestMethod
:
"GET"
,
Header
:
map
[
string
][]
string
{},
Header
:
Header
{},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
Body
:
nopCloser
{
bytes
.
NewBufferString
(
"abcdef"
)},
ContentLength
:
6
,
ContentLength
:
6
,
TransferEncoding
:
[]
string
{
"chunked"
},
TransferEncoding
:
[]
string
{
"chunked"
},
...
...
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