curl-users
Re: problem with POST on Redirecting! ( segmentation fault )
Date: Tue, 3 Dec 2002 11:24:01 +0100 (MET)
On Tue, 3 Dec 2002, Sanjeev wrote:
> curl -D SESS -d "test1user=myname" -d "test1pass=mypass" -d
> "button=Log%20in" http://www.xxx.com/create.php
Using -c is much better than -D for storing cookies.
> and then Posted data successfully with
> curl -b SESS -d
> "name=value&name=value&name=value&submit=Submit"
> http://www.xxx.com/create.php
> THIS IS DONE SUCCESSFULLY
> -----------------------------------------------------
> THe Failed program:
> ( since it is failing due to redirection, i needed to
> use the '-L' option )
> -------------------
> COMMAND::
> curl -v -D TESTING -d "test1user=sanjeev" -d
> "test1pass=sanjeev" -d "button=Login" -L
> http://web.xxx.com/yyy/create.php
> -------------------
> OUTPUT::
>
> * About to connect() to web.xxx.com:80
> * Connected to web.xxx.com (192.168.0.59) port 80
> > POST /yyy/create.php HTTP/1.1
> User-Agent: curl/7.10.2 (i686-pc-linux-gnu)
> libcurl/7.10.2 OpenSSL/0.9.6c zlib/1.1.3
> Host: web.xxx.com
> Pragma: no-cache
> Accept: image/gif, image/x-xbitmap, image/jpeg,
> image/pjpeg, */*
> Content-Length: 48
> Content-Type: application/x-www-form-urlencoded
>
> test1user=sanjeev&test1pass=sanjeev&button=Login*
> Follow to new URL:
> http://web.xxx.com/horde/login.php?Horde=a36591da71ffbddbd672330772cc9e03&url=%2Fyyy%2Fcreate.php%3FHorde%3Da36591da71ffbddbd672330772cc9e03
> * Connection #0 left intact
> * Follows Location: to new URL:
> 'http://web.xxx.com/horde/login.php?Horde=a36591da71ffbddbd672330772cc9e03&url=%2Fyyy%2Fcreate.php%3FHorde%3Da36591da71ffbddbd672330772cc9e03'
> * Disables POST, goes with GET
> * Re-using existing connection! (#0)
> Segmentation fault
>
> ----------------
> See the segmentation fault!
The "Segmentation fault" is of course a bug. Can you run gdb on the core to
get a stack trace to show us?
> 1) According to the Documentation, on a redirection GET takes over POST.
> But my login page needed a POST! what should i do?
Actually, curl reads the HTTP code that is returned by the server and acts
accordingly. The numeric tells curl weather to do a second POST or to switch
over to GET.
If you think curl does the wrong thing when you use -L, you can always remove
the -L and do the operations "manually" the way you think is better.
> 2) Lets say I could manage some how with the POST/GET of the login page,
> But as you saww above, i needed to copy the Followed URL twice MANUALLY to
> get the login page. Couldn't this be automated!
I saw that you faced a core dump. That needs to be fixed and when that is
fixed, we might have a different situation.
But sometimes it isn't possible to have curl do everything by itself
automaticly. Sometimes you just need to script it a bit yourself.
> 3) Finally, -D TESTING, dumped the session to the file TESTING, but on
> using the -L option, all the headers, it passed through redirection were
> appended to this same file, until the Final URL. NOW if lets say, the login
> is successfull, then the returned session is towards the end of the file
> 'TESTING' after all the redirected url's headers!
> Now if I use -b TESTING, will that will it read the session from the end
> of the file?? i mean the succesful header part of the TESTING??
So don't use -D, it easily confuses further curl uses exactly the way you
describe. Switch over to use -c instead, as that is much better way to store
cookies between separate curl invokes.
> 4) also, could you please explain me why cant i submit the LOGIN pages with
> -u "myusername:mypassword" ??
I seriously doubt you can do that. If you need to fill in your name and
password in a HTML form, then the -u is not the option you need. -u is for
HTTP authentication only.
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002enReceived on 2002-12-03