Am Dienstag, 3. März 2015 14:38:58 UTC+1 schrieb seb....@gmail.com:
I can read and parse the file, but CookieJar seem to require the URL of
the resource that set the cookie, which is not present in cookies.txt.
The relevant information to reconstruct a usable URL for SetCookie are in
cookies.txt file: the domain attribute

1) Would it break the contract with net/http CookieJar to allow nil URLs?
It's not explicitly forbidden in the documentation, but Jar in
net/http/cookiejar does not handle this case.
Yes that would be illegal: Not all cookies/URL-pairs are legal combinations
and the cookiejar has to decide which to reject (e.g. you cannot set a
cookie for facebook.com from evilhost.bad)

2) Are there implementations of CookieJar's that supports nil URLs and/or
loading cookies from a cookies.txt file?
I hope not (for the first part)! These would be deadly dangerous to use.
Loading from cookies.txt is simple (see below) and doesn't need a nil URL.

3) Would it be possible/desirable to add support for nil-URLs to
Jar#SetCookie implemented in net/http/cookiejar? I could try my best at
implementing it.
No, because of the reasons mentioned above.

To your problem: Just craft an artificial URL from the cookie domain and
the cookie path.
Let's say you have in your cookie.txt
     mydomain.org true /some/path ....
just use http://mydomain.org/ in SetCookie which should work. IMHO not even
path is necessary (but test that, it has been I while took a look at the


You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 3, '15 at 1:38p
activeMar 3, '15 at 5:19p



site design / logo © 2022 Grokbase