[#201] update required library, failing to populate cookiejar from cookies file

This commit is contained in:
Cory Bennett
2018-08-04 14:20:03 -07:00
parent a87bdf4038
commit ee69afadd0
2 changed files with 8 additions and 5 deletions
Generated
+1 -1
View File
@@ -39,7 +39,7 @@
branch = "master" branch = "master"
name = "github.com/coryb/oreo" name = "github.com/coryb/oreo"
packages = ["."] packages = ["."]
revision = "efd7a2135270bc44f64af39446c7226057e6953d" revision = "3e1b88fc08f134aa91ccfb5d58c983ca8ab42589"
[[projects]] [[projects]]
name = "github.com/davecgh/go-spew" name = "github.com/davecgh/go-spew"
+7 -4
View File
@@ -182,11 +182,14 @@ func (c *Client) initCookieJar() (err error) {
return err return err
} }
for _, cookie := range cookies { for _, cookie := range cookies {
url, err := url.Parse(cookie.Domain) // this is dumb, cookie.Domain *must not* have a scheme or port url.Parse will parse strings like "localhost"
if err != nil { // into the Path variable, not Host. So lets just force Host. We also need to set arbitrary http/https Scheme
return err // as Jar.SetCookies will ignore cookies where the url does not have a http/https Scheme
u := &url.URL{
Scheme: "http",
Host: cookie.Domain,
} }
c.Jar.SetCookies(url, []*http.Cookie{cookie}) c.Jar.SetCookies(u, []*http.Cookie{cookie})
} }
return nil return nil
} }