aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/requestwrite_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-06-16 13:02:28 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2011-06-16 13:02:28 -0700
commit6e9b1a78ff1a394a60a815b23564ad58a0cf0ce1 (patch)
tree86b7a721c37bbc18fdfda1a6b78b5547b3affd5f /src/pkg/http/requestwrite_test.go
parent7f3e109d2f89eb997cd28adc607fd75ba9ac94d1 (diff)
downloadgo-6e9b1a78ff1a394a60a815b23564ad58a0cf0ce1.tar.xz
http: make Headers be source of truth
Previously Request and Response had redundant fields for Referer, UserAgent, and cookies which caused confusion and bugs. It also didn't allow us to expand the package over time, since the way to access fields would be in the Headers one day and promoted to a field the next day. That would be hard to gofix, especially with code ranging over Headers. After a discussion on the mail package's design with a similar problem, we've designed to make the Headers be the source of truth and add accessors instead. Request: change: Referer -> Referer() change: UserAgent -> UserAgent() change: Cookie -> Cookies() new: Cookie(name) *Cookie new: AddCookie(*Cookie) Response: change: Cookie -> Cookies() Cookie: new: String() string R=rsc CC=golang-dev https://golang.org/cl/4620049
Diffstat (limited to 'src/pkg/http/requestwrite_test.go')
-rw-r--r--src/pkg/http/requestwrite_test.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pkg/http/requestwrite_test.go b/src/pkg/http/requestwrite_test.go
index 98fbcf459b..43ad5252d3 100644
--- a/src/pkg/http/requestwrite_test.go
+++ b/src/pkg/http/requestwrite_test.go
@@ -47,13 +47,12 @@ var reqWriteTests = []reqWriteTest{
"Accept-Language": {"en-us,en;q=0.5"},
"Keep-Alive": {"300"},
"Proxy-Connection": {"keep-alive"},
+ "User-Agent": {"Fake"},
},
- Body: nil,
- Close: false,
- Host: "www.techcrunch.com",
- Referer: "",
- UserAgent: "Fake",
- Form: map[string][]string{},
+ Body: nil,
+ Close: false,
+ Host: "www.techcrunch.com",
+ Form: map[string][]string{},
},
nil,
@@ -233,6 +232,9 @@ func TestRequestWrite(t *testing.T) {
if tt.Body != nil {
tt.Req.Body = ioutil.NopCloser(bytes.NewBuffer(tt.Body))
}
+ if tt.Req.Header == nil {
+ tt.Req.Header = make(Header)
+ }
var braw bytes.Buffer
err := tt.Req.Write(&braw)
if err != nil {