net/http: support for cookies when https

This commit is contained in:
sago35
2022-07-24 12:21:44 +09:00
committed by Ron Evans
parent 625c565c0b
commit 594ba1dab2
+5 -6
View File
@@ -20,6 +20,11 @@ func SetBuf(b []byte) {
}
func (c *Client) Do(req *Request) (*Response, error) {
if c.Jar != nil {
for _, cookie := range c.Jar.Cookies(req.URL) {
req.AddCookie(cookie)
}
}
switch req.URL.Scheme {
case "http":
return c.doHTTP(req)
@@ -31,12 +36,6 @@ func (c *Client) Do(req *Request) (*Response, error) {
}
func (c *Client) doHTTP(req *Request) (*Response, error) {
if c.Jar != nil {
for _, cookie := range c.Jar.Cookies(req.URL) {
req.AddCookie(cookie)
}
}
// make TCP connection
ip := net.ParseIP(req.URL.Hostname())
port := 80