app to look/view/inspect http traffic...

bruce bedouglas at earthlink.net
Thu Jun 10 00:20:27 UTC 2004


rhesa...

i tried that...

and it didn't work!!! i've tried a number of variations on the following
code...

if you can see where i've made an error..feel free to point it out...

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
use WWW::Mechanize;


$ua = new LWP::UserAgent;
$jar = new HTTP::Cookies;
$ua->timeout(30);
$ua->agent("AgentName/0.1 " . $ua->agent);

$ua->cookie_jar($jar);
push @{$ua->requests_redirectable}, 'POST';

### test using libwww

$p_url = "http://soc.our.psu.edu/soc/main_search.cfm";
$req = new HTTP::Request POST => $p_url;
$req->content_type('application/x-www-form-urlencoded');

$semester = "FALL%202004";
$crsealpha = "a%2Dc";
$crseloc = "AA%3A%3AAltoona%20Campus";
$cecrseloc = "";

$cstr = $cstr . "?Semester=".$semester;
$cstr = $cstr . "&CrseAlpha=".$crsealpha;
$cstr = $cstr . "&CrseLoc=".$crseloc;
$cstr = $cstr . "&CECrseLoc=".$cecrseloc;
$cstr = $cstr . "&CourseAbbrev=0&CourseNum=0";

$cstr1 =
"?Semester=FALL%202004&CrseLoc=&CECrseLoc=&CourseAbbrev=0&CrseAlpha=&CourseN
um=0";

$req->content($cstr1);
$agent = $ua->request($req);

print "-------------111111111----------\n";

print "agent->code = ". $agent->code(). "\n";
print "agent->msg = ". $agent->message(). "\n";
print "agent->base = ". $agent->base. "\n";
print "agent->hdr = ". $agent->headers_as_string(). "\n";
#print "agent->cont = ". $agent->as_string. "\n";
#print "agent->req = ". $agent->request(). "\n";

$cstr2 = "?Semester=FALL%202004&CrseLoc=AA%3A%3AAltoona%20Campus" .
        "&CECrseLoc=&CourseAbbrev=0&CrseAlpha=&CourseNum=0";
$req->content($cstr2);
$agent = $ua->request($req);

print "-------------2222222222----------\n";

print "agent->code = ". $agent->code(). "\n";
print "agent->msg = ". $agent->message(). "\n";
print "agent->base = ". $agent->base. "\n";
print "agent->hdr = ". $agent->headers_as_string(). "\n";
#print "agent->cont = ". $agent->as_string. "\n";
#print "agent->req = ". $agent->request(). "\n";


$cstr3 = "?Semester=FALL%202004&CrseLoc=AA%3A%3AAltoona%20Campus" .
        "&CECrseLoc=&CourseAbbrev=0&CrseAlpha=a%2Dc&CourseNum=0";
$req->content($cstr3);
$agent = $ua->request($req);

print "-------------33333333----------\n";

print "agent->code = ". $agent->code(). "\n";
print "agent->msg = ". $agent->message(). "\n";
print "agent->base = ". $agent->base. "\n";
print "agent->hdr = ". $agent->headers_as_string(). "\n";
#print "agent->cont = ". $agent->as_string. "\n";
#print "agent->req = ". $agent->request(). "\n";

die;

$q1c = $agent->content();

   print $agent->content();


i even thought at one time, that the app might be using cookies..although i
had disabled cookies from my browser... i thought that the app may have
somehow being keeping track of what the user was selecting during the
submission of the form.. so i emulated a user submitting an item at a time,
with the form doing the subsequent updates.. with no luck....

but i'm firmly of the belief that it's somehoe doing an internal redirect,
and sending the 302/redirect to the client browser...

-bruce





-----Original Message-----
From: perl-win32-users-bounces at listserv.ActiveState.com
[mailto:perl-win32-users-bounces at listserv.ActiveState.com]On Behalf Of
Rhesa Rozendaal
Sent: Wednesday, June 09, 2004 4:55 PM
To: bedouglas at earthlink.net; perl-win32-users at listserv.ActiveState.com
Subject: Re: app to look/view/inspect http traffic...


Hi Bruce,

This will solve your problems:

	push @{ $ua->requests_redirectable }, 'POST';

LWP::UserAgent by default won't automatically follow redirects that
result from a POST request, so this is how we tell it to do it anyway.

> mark...
>
> after a thorough inspection of the headers... (finally!!).. the server
> returns a 302 (object moved) along with the new location of the page...
>
> so my question is, how can libwww be used to detect/process this
> information. i assumed that the information should somehow be in the
> request/response method of the useragent.. but i couldn't seem to get my
> hands around how it should perform...
>
> the headers are as follows:

[snip]

> http://soc.our.psu.edu/soc/main_search.cfm
>
> POST /soc/main_search.cfm HTTP/1.1

[...]

> HTTP/1.x 302 Object Moved
> Location:
>
act_main_search.cfm?Semester=FALL%202004&CrseLoc=AA%3A%3AAltoona%20Campus&CE
> CrseLoc=&CourseAbbrev=0&CrseAlpha=a%2Dc&CourseNum=0


[snip]

HTH,

Rhesa
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users at listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs





More information about the redhat-list mailing list