FAQ
Hello,

I have a use-case where I need to initialize a CookieJar from net/http with
the cookies defined in a Netscape cookies.txt style file. wget, curl uses
this format.

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.

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.
2) Are there implementations of CookieJar's that supports nil URLs and/or
loading cookies from a cookies.txt file?
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.

//Sebastian

--
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

  • Ibrahim M. Ghazal at Mar 3, 2015 at 2:40 pm
    Wouldn't that be (domain + path) or am I missing something?

    --
    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.
  • Volker Dobler at Mar 3, 2015 at 5:19 pm

    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
    the
    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
    domain
    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
    the
    path is necessary (but test that, it has been I while took a look at the
    spec).

    V.

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 3, '15 at 1:38p
activeMar 3, '15 at 5:19p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase