CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
302 Object Moved Error

 



dkhanna01
Novice

Dec 6, 2004, 3:34 AM

Post #1 of 9 (1513 views)
302 Object Moved Error Can't Post

I have created a code from which I am getting and 302 Object Moved error:

Here is my code:

use HTML::Entities; # encode and decode things like <, >, and &
use HTML::Form; # for form processing
use HTTP::Cookies; # keep track of cookie
use HTTP::Request::Common;
use LWP::UserAgent; # pretend we are a browser
use Data::Dumper;
use Exporter;
use LWP::Debug qw(+);
use strict;


my $url = 'https://interddt.com/cqweb/logon/default_content.asp';

my $browser = LWP::UserAgent->new;

my $response = $browser->request(POST "$url", [ DatabaseName => 'TECH', User => '<user id>', Password => '<password>' ]);
die "Error at $url\n ", $response->status_line, "\n Aborting"
unless $response->is_success;
print "Whee, it worked! I got that ",
$response->content_type, " document!\n";


And here is the output of the LWP debug trace from this code

#> perl ./test.pl
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: POST
https://dtinterddt.digitalthink.com/cqweb/logon/default_content.asp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: POST /cqweb/logon/default_content.asp HTTP/1.0
Host: dtinterddt.digitalthink.com
User-Agent: libwww-perl/5.53
Content-Length: 48
Content-Type: application/x-www-form-urlencoded


LWP::Protocol::http::request: POST /cqweb/logon/default_content.asp HTTP/1.0
Host: dtinterddt.digitalthink.com
User-Agent: libwww-perl/5.53
Content-Length: 48
Content-Type: application/x-www-form-urlencoded


LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.1 302 Object moved
Server: Microsoft-IIS/5.0
Date: Mon, 06 Dec 2004 10:58:27 GMT
Location: /cqweb/default_content.asp
Connection: Keep-Alive
Content-Length: 121
Content-Type: text/html
Set-Cookie: CQWebUsrSettings=LOGON%5FUSER=dkhanna&LOGON%5FDBSET=2002%252e05%252e00&LOGON%5FDB=TECH; expires=Mon, 27-Dec-2004 08:00:00 GMT; path=/
LWP::Protocol::http::request: HTTP/1.1 302 Object moved
LWP::Protocol::http::request: need more header data
LWP::Protocol::collect: read 21 bytes
LWP::Protocol::collect: read 100 bytes
LWP::UserAgent::request: Simple response: Found
Error at
https://dtinterddt.digitalthink.com/cqweb/logon/default_content.asp
302 Object moved
Aborting at ./test.pl line 16


Can anybody help me how to resolve this issue


kencl
User

Dec 8, 2004, 1:46 AM

Post #2 of 9 (1510 views)
Re: [dkhanna01] 302 Object Moved Error [In reply to] Can't Post

Redirecting of POST requests is not enabled by default. Just add the second line (the first one is already in your code)

Code
my $browser = LWP::UserAgent->new; 
push(@{$broswer -> requests_redirectable}, 'POST');


>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


dkhanna01
Novice

Dec 8, 2004, 3:59 AM

Post #3 of 9 (1508 views)
Re: [kencl] 302 Object Moved Error [In reply to] Can't Post

I afraid but it does not works as I am using perl 5.6.1 and it gives me error as "Can't locate object method "requests_redirectable" via package "LWP::UserAgent" (perhaps you forgot to load "LWP::UserAgent"?)".

So does that mean I have to install new version of perl (which I really do not want to) or if there is any other alternative available.


kencl
User

Dec 8, 2004, 1:04 PM

Post #4 of 9 (1505 views)
Re: [dkhanna01] 302 Object Moved Error [In reply to] Can't Post

It means you need to upgrade the LWP::UserAgent module. Older versions simply denied redirection for POST operation, the the requests_redirectable method was added to give you more control over which type of requests can and cannot be redirected

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!

(This post was edited by kencl on Dec 8, 2004, 1:09 PM)


dkhanna01
Novice

Dec 8, 2004, 8:44 PM

Post #5 of 9 (1499 views)
Re: [kencl] 302 Object Moved Error [In reply to] Can't Post

Thanks for the reply.

I'll try this with new version of libwww-perl 5.802. But I have Crypt::SSLeay module already installed on the older version. Does that means after upgrading to libwww:perl 5.8 from 5.53 I again need to install the Crypt:SSleay module ?

//Deep


kencl
User

Dec 8, 2004, 9:07 PM

Post #6 of 9 (1497 views)
Re: [dkhanna01] 302 Object Moved Error [In reply to] Can't Post

In theory, no, in practice, maybe :/ Probably not actually, but the only way to tell is to try it.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


dkhanna01
Novice

Dec 9, 2004, 2:51 AM

Post #7 of 9 (1489 views)
Re: [kencl] 302 Object Moved Error [In reply to] Can't Post

I have tried to run the same script after installing the libwww-perl, but this also does not helps. Now it is not giving any error but neither it is taking me to the next screen after authentication.

This what I am getting

HTTP/1.1 200 OK
Cache-Control: private
Connection: close
Date: Thu, 09 Dec 2004 10:46:00 GMT
Server: Microsoft-IIS/5.0
Content-Type: text/html
Content-Type: text/html
Charset: iso-8859-15
Client-Date: Thu, 09 Dec 2004 10:46:00 GMT
Client-Peer: 64.95.127.214:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Server CA/Email=server-certs@thawte.com
Client-SSL-Cert-Subject: /C=US/ST=California/L=San Francisco/O=DigitalThink Inc/OU=DTSFO/CN=dtinterddt.digitalthink.com
Client-SSL-Cipher: RC4-MD5
Client-SSL-Warning: Peer certificate not verified
Set-Cookie: ASPSESSIONIDCQRBQTBC=EIJNEGJDJAGLGMJFPCGHNNJO; path=/




And the response actually prints the same logon page after the POST query.


kencl
User

Dec 9, 2004, 5:02 AM

Post #8 of 9 (1485 views)
Re: [dkhanna01] 302 Object Moved Error [In reply to] Can't Post

Then some other HTTPS header is missing or incorrect according to the page you are being redirected to. Track the headers for a successful login and compare them to what you are sending. I just use Mozilla with the LiveHTTPHeaders add in. http://livehttpheaders.mozdev.org/.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


dkhanna01
Novice

Dec 9, 2004, 9:45 PM

Post #9 of 9 (1474 views)
Re: [kencl] 302 Object Moved Error [In reply to] Can't Post

Hi

I am not sure how the get the https header information from the script. Actually one more thing my logon page is actually asp page with 3 frames, does that causing any problems ?

Best Regards

Deep

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives