1
0
mirror of https://github.com/golang/go synced 2024-11-21 16:54:46 -07:00

net/http: set cookies in client jar on POST requests.

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
This commit is contained in:
Volker Dobler 2012-01-29 14:16:11 -05:00 committed by Russ Cox
parent 71d83b72ef
commit d91ade02e7

View 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,