resty
resty copied to clipboard
error cookie domain
import (
"github.com/go-resty/resty/v2"
"net/http"
)
func main() {
client := resty.New()
client.SetCookie(&http.Cookie{Name: "Hi", Value: "word", Domain: ".google.com"})
resp, _ := client.R().Get("http://www.httpbin.org/anything")
println(resp.String())
}
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip",
"Cookie": "Hi=word",
"Host": "www.httpbin.org",
"User-Agent": "go-resty/2.6.0 (https://github.com/go-resty/resty)",
"X-Amzn-Trace-Id": "Root=1-6087b57d-10e1f3904a5713720a5d73cd"
},
"json": null,
"method": "GET",
"origin": "61.165.29.81",
"url": "http://www.httpbin.org/anything"
}
When I use client to set up cookie, I should need to determine the domain. of cookie
github.com/go-resty/resty/[email protected]/middleware.go:createHTTPRequest:185
// Add cookies from client instance into http request
for _, cookie := range c.Cookies {
r.RawRequest.AddCookie(cookie)
}
@yuelwish I'm sorry for the delay response. Could you provide more details? I'm unable to understand the issue.