]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: set cookies in client jar on POST requests.
authorVolker Dobler <dr.volker.dobler@gmail.com>
Sun, 29 Jan 2012 19:16:11 +0000 (14:16 -0500)
committerRuss Cox <rsc@golang.org>
Sun, 29 Jan 2012 19:16:11 +0000 (14:16 -0500)
Cookies recieved in a response to a POST request are stored
in the client's jar like they are for GET requests.

R=golang-dev, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/5576065

src/pkg/net/http/client.go

index c9f024017573ea107bb42443a3b56f80badea05a..09afd5ef1d077ba88cb42954c66c251c489c1981 100644 (file)
@@ -274,7 +274,11 @@ func (c *Client) Post(url string, bodyType string, body io.Reader) (r *Response,
                return nil, err
        }
        req.Header.Set("Content-Type", bodyType)
-       return send(req, c.Transport)
+       r, err = send(req, c.Transport)
+       if c.Jar != nil {
+               c.Jar.SetCookies(req.URL, r.Cookies())
+       }
+       return r, err
 }
 
 // PostForm issues a POST to the specified URL,