Golang net/http.Response.Cookies() and Location() functions example
package net/http
Golang net/http.Response.Cookies() and Location() functions usage example
...
var network string // private
var address string // private
var Jar CookieJar // public
conn, err := net.Dial(network, address)
if err != nil {
panic(err)
}
resp, err := http.ReadResponse(bufio.NewReader(conn), &http.Request{Method: "CONNECT"})
if err == nil && resp.Status == connected {
if rc := resp.Cookies(); len(rc) > 0 { // <----------- here!
Jar.SetCookies(targetURL, rc)
locationURL, err := resp.Location() //<----- here !
if err != nil {
fmt.Println("Location URL error ", err)
return
}
}
}
if err == nil {
err = errors.New("unexpected HTTP response: " + resp.Status)
}
conn.Close()
...
References :
Advertisement
Something interesting
Tutorials
+6.9k Golang : How to solve "too many .rsrc sections" error?
+4.7k PHP : Extract part of a string starting from the middle
+19.9k Golang : How to get time from unix nano example
+10.2k Golang : Bcrypting password
+28.5k Golang : Change a file last modified date and time
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+10.1k Golang : Check a web page existence with HEAD request example
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+11.4k Golang : Concatenate (combine) buffer data example
+6.8k Get Facebook friends working in same company
+22.7k Golang : Strings to lowercase and uppercase example
+10.5k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery