cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to get around 302 Object Moved....

From: R. Blaine Mincey <blaine_mincey_at_mindspring.com>
Date: Wed, 23 Nov 2005 09:55:07 -0500

 Thanks a million for the reply Daniel. Next time I will post at the
curl-library list as you suggested.

What actually happens in the script is that when I receive the 302 status,
the action I am doing an HTTP get on is not executing. And, in looking at
the output from libcurl, it indicates I need to issue another request to the
login url. I guess this is what is confusing me as I am logging in with my
digital cert, parsing data, and when I get the 302, it is indicating I need
to login. What further confuses me is that this is executing in a loop.
Later on in the loop I do another HTTP Get to traverse a record set and it
still lets me perform it thus indicating I am still logged in.

Am I just interpreting the libcurl output wrong? I am beginning to wonder
if there is some type of session variable that is set at the server side. I
know I am sending pretty much exactly what needs to be sent as I am using
IEHeaders in IE and LiveHeaders for Firefox. Was trying to see if there was
any difference in the headers.

Thanks again for you help.

Blaine

From: Daniel Stenberg
<daniel_at_haxx.se<daniel_at_haxx.se?Subject=Re:%20How%20to%20get%20around%20302%20Object%20Moved....>>

Date: 2005-11-23

On Tue, 22 Nov 2005, R. Blaine Mincey wrote:

*> I have been utilizing libcurl via javacurl for quite a while now with
good *
*> success. *

Just note that the curl-library list might be more suitable for you...

*> Recently, my script is having some problems because of receiving a *
*> "302 Object Moved" http status. Basically, my script hits a URL, logs in
to *
*> a secure site via a digital certificate, performs some various
operations, *
*> then submits data via a get. After submitting the data, I receive the 302
*
*> status. By looking through the output, there is an indication that I must
*
*> "issue another request" to the login url. *
 I read your mail several times but I don't understand what your
problem/question is. libcurl has the power to follow redirects such as those
a
302 implies. Are you saying that you ask it to do that and it fails in doing

so?

On 11/22/05, R. Blaine Mincey <blaine_mincey_at_mindspring.com> wrote:
>
> Greetings all.
>
> I have been utilizing libcurl via javacurl for quite a while now with good
> success. Recently, my script is having some problems because of receiving a
> "302 Object Moved" http status. Basically, my script hits a URL, logs in to
> a secure site via a digital certificate, performs some various operations,
> then submits data via a get. After submitting the data, I receive the 302
> status. By looking through the output, there is an indication that I must
> "issue another request" to the login url.
>
> The code below is called after successfully logging in and parsing some
> values from various places on the site. The java code mirrors pretty much
> exactly what would be implemented via libcurl:
> cg.setopt(CURL.OPT_URL,"the url" );
> cg.setopt(CURL.OPT_VERBOSE, 1);
> cg.setopt(CURL.OPT_HTTPGET, 1);
> cg.setopt(CURL.OPT_FOLLOWLOCATION,1);
> cg.setopt(CURL.OPT_ENCODING,"gzip, deflate");
> cg.setopt(CURL.OPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows
> NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)");
>
>
> My output is below with the internal stuff marked out:
>
> ##### BEGIN of OUTPUT #############
>
> * About to connect() to sdnadmin port 443
> * Trying <an ip address>... * connected
> * Connected to sdnadmin (<an ip address>) port 443
> * SSL connection using RC4-MD5
> * Server certificate:
> * subject: <subject>
> * start date: 2005-06-22 00:00:00 GMT
> * expire date: 2006-06-22 23:59:59 GMT
> * issuer: <some cert authority>
> * SSL certificate verify result: error number 1 (20), continuing anyway.
> > GET <the url to get> HTTP/1.1
>
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET
> CLR 1.1.4322; InfoPath.1)
>
> Host: sdnadmin
>
> Pragma: no-cache
>
> Accept: */*
>
> Accept-Encoding: gzip, deflate
>
>
>
> < HTTP/1.1 302 Object Moved
> < Location: <the login url with the get url above as target>
>
> < Cache-control: no-cache
>
> * Connection #2 to host sdnadmin left intact
> * Issue another request to this URL: '<the login url with the get url
> above as target>'
> * About to connect() to <internal server> port 443
> * Trying <internal server ip address>... * connected
> * Connected to <internal server> (<internal server ip address) port 443
> * SSL re-using session ID
> * SSL connection using RC4-MD5
> * Server certificate:
> * subject: <subject>
> * start date: 2005-06-22 00:00:00 GMT
> * expire date: 2006-06-22 23:59:59 GMT
> * issuer: <some cert authority>
> * SSL certificate verify result: error number 1 (20), continuing anyway.
> > GET <the login url with the get url above as target> HTTP/1.1
>
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET
> CLR 1.1.4322; InfoPath.1)
>
> Host: <some host>
>
> Pragma: no-cache
>
> Accept: */*
>
> Accept-Encoding: gzip, deflate
>
> Cookie: <cookie stuff>
>
> ##### END of OUTPUT #############
>
> Thanks in advance for any feedback. I *hope* I did not do something
> ridiculous....although I will not be surprised if that is the case :)
>
> Blaine Mincey
>
Received on 2005-11-23