How golang gets the detailed process of the request?

72 Views Asked by At

I use cookiejar to manage cookies, but I can't get the correct result.

How to know whether a request carries the cookie correctly?

jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
client := &http.Client{
    Jar: jar,
}
req, _ := http.NewRequest("GET", "https://xxx", nil)
ParsedURL, _ := url.Parse("https://xxx")
fmt.Println("cookies1", client.Jar.Cookies(ParsedURL))
fmt.Println("cookies2",req.Cookies())
resp, _ := client.Do(req)
resp.Body.Close()

cookies1 is right

cookies2 is empty

So, can you see all the information like a browser's console?

0

There are 0 best solutions below