cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Passing cookies during session

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 18 Jan 2002 10:55:08 +0100 (MET)

On Thu, 17 Jan 2002, Lara Bordick wrote:

[my comments are inlined below]

> Using a web browser I can download a particular file that I need at the
> following URL by selecting the appropriate client certificate that is
> installed in my browser:
> https://dataserver.somesite.com/file_I_want_to_download.tar.gz
>
> What actually happens is that when I connect to the above URL, I am
> redirected to a different server, lets call it
> https://validationserver.somesite.com, which handles authentication and
> then sets a cookie which dataserver.somesite.com requires to determine that
> I am a valid user and then redirects me back to
> https://dataserver.somesite.com/file_I_want_to_download.tar.gz. At this
> point the browser begins the process of downloading this file.
>
> What I really want to do is to download these files using curl because of
> its ability to resume the file transfer where it left off in case of a
> broken connection.
>
> I have been able to make this process work using a two step process.
>
> The first command looks like this:
> curl -D cookies --cert my_cert.pem:password -L
> https://validationserver.somesite.com
>
> The second command looks like this:
> curl -b cookies --cert my_cert.pem:password -L
> https://dataserver.somesite.com/file_I_want_to_download.tar.gz
>
> Is there a way to do this in one step? The documentation led me to believe
> that I should be able to do this using only the second command.

I would say so now as well.

> In the tutorial it says "if you want to let curl understand cookies from a
> page and follow a location (and thus possibly send back cookies it
> received), you can invoke it like: curl -b nada -L www.cookiesite.com".
> However when I run the second command without doing the first I get stuck
> in a loop between the authentication server and the dataserver because curl
> does not appear to be passing the cookie received from the authentication
> server to the dataserver.

This sounds like a bug. I realize that this might contain sensitive data, but
do you think it would be possible for you to use -vi when you perform the
above commands to figure out what goes wrong? Check the 'Set-Cookie: lines
from the server and the 'Cookie:' line sent back by curl.

If you replace the names with suitably other values (as you did with the site
names) to prevent them to show anything you wouldn't want, we might still
understand why this happens or possibly work out a fix if this truly proves
to be a bug.

> What is the proper syntax for doing this in one step or is it not possible?

It is meant to work using that syntax!

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-01-18