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