FAQ
Hi,

I'm just following "Contribution Guidelines" ;-)

I want to write a patch
for https://code.google.com/p/go/issues/detail?id=3985

If you take a look at (description of func (c *Client) Do):
http://golang.org/src/pkg/net/http/client.go#L87
It says that:

// Do sends an HTTP request and returns an HTTP response, following// policy (e.g. redirects, cookies, auth) as configured on the client.

It's a true in a case of HEAD and GET requests.

Patch will look similar to:
func handleCookies(jar CookieJar, req *http.Request, transport
RoundTripper) (r *Response, err error) {
if jar != nil {
for _, cookie := range jar.Cookies(req.URL) {
req.AddCookie(cookie)
}
}
if r, err = send(req, c.Transport); err != nil {
return r, err
}
if c := r.Cookies(); jar != nil && len(c) > 0 {
jar.SetCookies(req.URL, c)
}
return r, err
}

and replacing
return send(req, c.Transport) with
return handleCookies(c.Jar, req, c.Transport)
Then it should be also possible to replace few lines here (
doFollowingRedirects):
http://golang.org/src/pkg/net/http/client.go#L223 and
http://golang.org/src/pkg/net/http/client.go#L27<http://golang.org/src/pkg/net/http/client.go#L223>
5
I think it would be a nice looking patch (need a better func name proposal).

That would fix at least a cookie problem.

Cheers, Pawel

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 10, '12 at 1:15a
activeSep 10, '12 at 1:15a
posts1
users1
websitegolang.org

1 user in discussion

Paweł Szczur: 1 post

People

Translate

site design / logo © 2022 Grokbase