• Brad Fitzpatrick's avatar
    http: make Headers be source of truth · 6e9b1a78
    Brad Fitzpatrick authored
    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
    6e9b1a78
child_test.go 2.5 KB