]> Cypherpunks repositories - gostls13.git/commit
http: make Headers be source of truth
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 16 Jun 2011 20:02:28 +0000 (13:02 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 16 Jun 2011 20:02:28 +0000 (13:02 -0700)
commit6e9b1a78ff1a394a60a815b23564ad58a0cf0ce1
tree86b7a721c37bbc18fdfda1a6b78b5547b3affd5f
parent7f3e109d2f89eb997cd28adc607fd75ba9ac94d1
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
18 files changed:
src/cmd/gofix/Makefile
src/cmd/gofix/httpheaders.go [new file with mode: 0644]
src/cmd/gofix/httpheaders_test.go [new file with mode: 0644]
src/cmd/gofix/main.go
src/pkg/http/cgi/child.go
src/pkg/http/cgi/child_test.go
src/pkg/http/cgi/host.go
src/pkg/http/client.go
src/pkg/http/client_test.go
src/pkg/http/cookie.go
src/pkg/http/cookie_test.go
src/pkg/http/readrequest_test.go
src/pkg/http/request.go
src/pkg/http/requestwrite_test.go
src/pkg/http/response.go
src/pkg/http/reverseproxy.go
src/pkg/http/reverseproxy_test.go
src/pkg/http/server.go