cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Newbie's question on cURL usage

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 28 Feb 2002 10:36:55 +0100 (MET)

On Wed, 27 Feb 2002, Yanhui Liu wrote:

Thanks for trying the upgrade and your continuos reporting.

> I upgraded to 7.9.5-pre4, however I still could not get the target page.

Ok. Still, this is a better version to chase bugs on. My comments follow
inlined below.

> >Yes, curl can read Netscape's cookies. Use -b for reading and -c can even
> >write them back in Netscape format.
>
> Wonderful. Does it mean curl can use netscape's cookie to retrieve pages?

Yes, it means that it reads cookies from the file and uses them accordingly
as it considers correct.

BTW, to get the *best* possible cookie state stored between separate curl
invokes, don't just dump the cookies into a header file with -D, use the
cookie jar (-c) functionality as that is a more complete file format. Not
that I think this is the cause of any problems here, I just thought it could
be noted.

> For example, I ran the curl test using netscape's cookie, which was
> generated after browsing the content.
>
> $ cp ~/.netscape/cookies .
> $ curl -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" -b cookies
> -L -v -i -s -o junk.DATA --url
> "http://moneycentral.msn.com/investor/quotes/pprtq.asp?Page=RTQ&Symbol=orcl"
> * Connected to moneycentral.com (207.46.189.14)
> > GET /investor/quotes/pprtq.asp?Page=RTQ&Symbol=orcl HTTP/1.1
> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
> Host: moneycentral.msn.com
> Pragma: no-cache
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
> Cookie:
> QUAUTH=66504305614a51425d57755e515248404e585a5478525906280e40640357114307215e07164b43455009;
> MC1=GUID=00D22A5A9CA043E6A8730ABFDF1F3195

This obviously made two cookies get sent to the remote server. Does that
match your opinion on what should've been sent?

> * Follows Location: to new URL:
> 'http://moneycentral.msn.com/pplogin.asp?Page=http://moneycentral.msn.com/investor/quotes/pprtq.asp&Query=Page%3DRTQ%26Symbol%3Dorcl%26REQUEST%5FMETHOD%3DGET&AuthTime=43200&ForceLogin=False'
> * Disables POST, goes with GET
> * Connected to moneycentral.com (207.46.189.14)
> > GET
> /pplogin.asp?Page=http://moneycentral.msn.com/investor/quotes/pprtq.asp&Query=Page%3DRTQ%26Symbol%3Dorcl%26REQUEST%5FMETHOD%3DGET&AuthTime=43200&ForceLogin=False
> HTTP/1.1
> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
> Host: moneycentral.msn.com
> Pragma: no-cache
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
> Cookie:
> QUAUTH=66504305614a51425d57755e515248404e585a5478525906280e40640357114307215e07164b43455009;
> MC1=GUID=00D22A5A9CA043E6A8730ABFDF1F3195
>
> * Follow to new URL:
> http://login.passport.com/login.srf?lc=1033&id=229&ru=http%3A%2F%2Fmoneycentral%2Emsn%2Ecom%2Fpploggedin%2Easp%3FPage%3Dhttp%253A%252F%252Fmoneycentral%252Emsn%252Ecom%252Finvestor%252Fquotes%252Fpprtq%252Easp%26Query%3DPage%253DRTQ%2526Symbol%253Dorcl%2526REQUEST%255FMETHOD%253DGET&tw=43200&kv=2&ct=1014877476&ver=2.0.0248.1&tpf=5b566e78f24697f753fdd1b608fd10b3
> * Closing connection #0
> * Follows Location: to new URL:
> 'http://login.passport.com/login.srf?lc=1033&id=229&ru=http%3A%2F%2Fmoneycentral%2Emsn%2Ecom%2Fpploggedin%2Easp%3FPage%3Dhttp%253A%252F%252Fmoneycentral%252Emsn%252Ecom%252Finvestor%252Fquotes%252Fpprtq%252Easp%26Query%3DPage%253DRTQ%2526Symbol%253Dorcl%2526REQUEST%255FMETHOD%253DGET&tw=43200&kv=2&ct=1014877476&ver=2.0.0248.1&tpf=5b566e78f24697f753fdd1b608fd10b3'
> * Disables POST, goes with GET
> * Connected to login.passport.com (64.4.60.254)
> > GET
> /login.srf?lc=1033&id=229&ru=http%3A%2F%2Fmoneycentral%2Emsn%2Ecom%2Fpploggedin%2Easp%3FPage%3Dhttp%253A%252F%252Fmoneycentral%252Emsn%252Ecom%252Finvestor%252Fquotes%252Fpprtq%252Easp%26Query%3DPage%253DRTQ%2526Symbol%253Dorcl%2526REQUEST%255FMETHOD%253DGET&tw=43200&kv=2&ct=1014877476&ver=2.0.0248.1&tpf=5b566e78f24697f753fdd1b608fd10b3
> HTTP/1.1
> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
> Host: login.passport.com
> Pragma: no-cache
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
> Cookie: MSPPre=llp_gapper_at_yahoo.com
>
> * Closing connection #0
>
> I still ended up at the login page. The content of the cookie file from
> netscape was shown in my first posting. So curl does not pass the cookie
> back to server correctly.

What makes you say that? Cookies are not the only way a server might use to
deny your requests. It could for example check the user-agent or refer
fields. I couldn't possibly tell.

If you check all Set-Cookie: lines you received plus the initial cookie jar
file, and then check what cookies curl sent in its requests. Can you detect a
problem (like a missing cookie or something) there?

> After second thought, I think if curl can use cookies from Netscape/IE,
> then we don't need this recording ability unless Netscape/IE change their
> format frequently.

Uh, no we can't use cookies from IE, they're not available that easily AFAIK.

The Netscape cookie file format has been the same for ages, and Mozilla is
using the same format, so we can probably safely expect that to remain for a
while more...

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-02-28