Closed shoaly closed 4 years ago
// cookies 是可以的,我写了一个测试的例子, request_test.go 里面有这个例子 // 我测试是成功的
req = Requests()
cookie := &http.Cookie{}
cookie.Name = "postcookie"
cookie.Value = "20200725"
cookie.Path = "/"
req.SetCookie(cookie)
//test post cookies
resp, err = req.Post("https://www.httpbin.org/post", data)
if err == nil {
coo := resp.Cookies()
// coo is [] *http.Cookies
println("********Post cookies*******")
for _, c := range coo {
fmt.Println(c.Name, c.Value)
}
}
额 我空了再试试看, 可能哪里理解错了 之前对go 还没那么了解 没仔细看源代码
` //reset Cookies,
//Client.Do can copy cookie from client.Jar to req.Header
delete(req.httpreq.Header, "Cookie") `
源文件里面还专门去掉了..... 导致现在想要发送一个自定义cookie的 post 非常复杂, 不够优雅, 不够初衷了
` req := requests.Requests() cookie := &http.Cookie{ Name: "cooke_name", Value: "cookie_value", } req.SetCookie(cookie)