curl-users
How to get around 302 Object Moved....
Date: Tue, 22 Nov 2005 14:28:40 -0500
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-22