cURL / Mailing Lists / curl-users / Single Mail

curl-users

Cookie awareness (was: curl win32 commandline question)

From: Kevin P Roth <kproth_at_MarathonOil.com>
Date: Fri, 16 Mar 2001 10:53:58 -0600

With regards to my memory of not being able to use -b and -D at the same
time with the same file ¯ I must be smoking bad crack. I went back and
tried again (w/ curl 7.5.1) and it appears to work flawlessly. So never
mind on that count...

Here's a followup question regarding cookie awareness: with the new
options in place for requesting multiple URLs in the same call to curl,
will cookie-awareness continue to work? Does it change in any way?

Here's the example I'm thinking about, if it helps answer my question:

Right now I'm downloading a file of prices from fidelity.com with the
following 4 generic curl calls:

1: curl <login-screen-url>

   o this gets me a server name to post the login data to

2: curl <login-processing-screen-url> --referer <login-screen-url>
   -d User=Me&Password=it -D cookie-file

   o this logs me in and returns a couple cookies to store

3: curl <intermediate-page-url> -b cookie-file -D cookie-file

   o this page sets another cookie related to my session, I can't
     use -L because it uses javaScript, not Location: headers

4: curl <data-url> -b cookie-file -o data-file

   o this page has my data, it requires the cookies to lookup my
     session and realize I'm logged in and have visited the
     intermediate page first

In this particular example, #2-4 are all on the same server, while #1 is
on a different machine. With the new ability to submit multiple urls at
the same time, I'd envision changing this so it only needs one call to
curl with the four URLs at once. But it would still need to hit the four
pages in the same order, and it would still need to track and send the
cookies to each subsequent URL.

Thanks,
--Kevin

>>> Daniel Stenberg <daniel_at_haxx.se> 3/15/01 2:29 AM >>>
You can do this by running "curl -D file URL1" and then "curl -b file URL2"
in two shots, but if the URL1 returns a Location: to URL2, you can have the
same effect (cookie-wise) with: "curl -L -b fakefile URL1".

Storing headers is best used when not doing -L, as curl can't separate
cookies from individual requests in a header dump (when later using -b on the
header dump) that is the result of many requests. It isn't necessarily a bad
thing though.

> I remember trying before using the same file in both -D and -b, and it
> seems that the prior contents of that file were getting overwritten and
> it wasn't really working as intended...

I've intended those two options to be able to use the same file. -b reads the
file initially and -D only writes to the file first when it has data to write
and that happens after the reading is done.

Can you show us an example where this fails?
Received on 2001-03-16