mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
http: remove finalURL from Client.Get; move to Response
This CL:
-- removes Response.RequestMethod string
-- adds Response.Request *Request
-- removes the finalURL result parameter from client.Get()
-- adds a gofix rule for callers of http.Get which assign
the final url to the blank identifier; warning otherwise
Caller who did:
res, finalURL, err := http.Get(...)
now need to do:
res, err := http.Get(...)
if err != nil {
...
}
finalURL := res.Request.URL.String()
R=rsc
CC=golang-dev
https://golang.org/cl/4535056
This commit is contained in:
parent
4336116d3b
commit
05a1b7ec41
22 changed files with 203 additions and 100 deletions
|
|
@ -126,13 +126,10 @@ func shouldRedirect(statusCode int) bool {
|
|||
// 303 (See Other)
|
||||
// 307 (Temporary Redirect)
|
||||
//
|
||||
// finalURL is the URL from which the response was fetched -- identical to the
|
||||
// input URL unless redirects were followed.
|
||||
//
|
||||
// Caller should close r.Body when done reading from it.
|
||||
//
|
||||
// Get is a convenience wrapper around DefaultClient.Get.
|
||||
func Get(url string) (r *Response, finalURL string, err os.Error) {
|
||||
func Get(url string) (r *Response, err os.Error) {
|
||||
return DefaultClient.Get(url)
|
||||
}
|
||||
|
||||
|
|
@ -145,11 +142,8 @@ func Get(url string) (r *Response, finalURL string, err os.Error) {
|
|||
// 303 (See Other)
|
||||
// 307 (Temporary Redirect)
|
||||
//
|
||||
// finalURL is the URL from which the response was fetched -- identical
|
||||
// to the input URL unless redirects were followed.
|
||||
//
|
||||
// Caller should close r.Body when done reading from it.
|
||||
func (c *Client) Get(url string) (r *Response, finalURL string, err os.Error) {
|
||||
func (c *Client) Get(url string) (r *Response, err os.Error) {
|
||||
// TODO: if/when we add cookie support, the redirected request shouldn't
|
||||
// necessarily supply the same cookies as the original.
|
||||
var base *URL
|
||||
|
|
@ -198,7 +192,6 @@ func (c *Client) Get(url string) (r *Response, finalURL string, err os.Error) {
|
|||
via = append(via, &req)
|
||||
continue
|
||||
}
|
||||
finalURL = url
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue