B
badnewswade
Hi. I'm learning perl and I'm having terrible trouble with using the
POST method in HTTP::Request and LWP::UserAgent. I'm using the Win32
distro, downloaded it a couple of weeks ago.
Here's some source code:
#!/usr/bin/perl -w
#
#
#use diagnostics;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
$AgentSmith = new LWP::UserAgent;
$httpRequest = new HTTP::Request;
#$httpResponse = new HTTP::Response;
$address='http://badnews.inksco.com/index.php?action=login';
$thingToPost='passwor';
$output = $AgentSmith->post($address, ['password'=> $thingToPost,
PHPSESSID=> '96febde8d8496f962bc74ea5549ab30b']);
&AgentSmith;
die "Program ended normally";
sub AgentSmith{
$output = $AgentSmith->request($httpRequest); #These three lines
actually do the request
$OutputContent = $output->content; #then put the content in a variable
print $OutputContent; #then print the variable. (stick 'em in a
sub?)
$ResponseCode = $output ->code;
print "\n_____________________________________________________________
\n";
print "\n \n Agent Smith called. httpRequest is $httpRequest \n
"; #Debugging message.
print "repsonse code is $ResponseCode";
print "\n_____________________________________________________________
\n";
}
This is the program's output:
400 Method missing
_____________________________________________________________
Agent Smith called. httpRequest is HTTP::Request=HASH(0x18443b0)
repsonse code is 400
_____________________________________________________________
Uncaught exception from user code:
Program ended normally at C:\perl-progs\login-inksco.pl line
19.
at C:\perl-progs\login-inksco.pl line 19
If you run it do you also get that stupid )*&&^%ing error? (I'm not
talking about user exception either - that's just the debugger talking)
All I EVER get out of this garbage is "400 Method Missing". I've tried
and tried, and have come to the conclusion that either PERL clients
can't use the POST method, or PERL is a useless piece of crap, or my
copy of PERL (Win32) is somehow broken.
This is driving me round the bend. Every time I try try using it to
POST I get the same, asinine error message. "400 Method Missing".
Can someone tell me what I'm doing wrong and whether I should try
another language? I like PERL, it's nice 'n' easy, like BASIC or PASCAL
but with Internet support and its widely used, but it really has
dissapointed me on this score. BTW, the GET method works just fine...
Cheers
Andy Wade
POST method in HTTP::Request and LWP::UserAgent. I'm using the Win32
distro, downloaded it a couple of weeks ago.
Here's some source code:
#!/usr/bin/perl -w
#
#
#use diagnostics;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
$AgentSmith = new LWP::UserAgent;
$httpRequest = new HTTP::Request;
#$httpResponse = new HTTP::Response;
$address='http://badnews.inksco.com/index.php?action=login';
$thingToPost='passwor';
$output = $AgentSmith->post($address, ['password'=> $thingToPost,
PHPSESSID=> '96febde8d8496f962bc74ea5549ab30b']);
&AgentSmith;
die "Program ended normally";
sub AgentSmith{
$output = $AgentSmith->request($httpRequest); #These three lines
actually do the request
$OutputContent = $output->content; #then put the content in a variable
print $OutputContent; #then print the variable. (stick 'em in a
sub?)
$ResponseCode = $output ->code;
print "\n_____________________________________________________________
\n";
print "\n \n Agent Smith called. httpRequest is $httpRequest \n
"; #Debugging message.
print "repsonse code is $ResponseCode";
print "\n_____________________________________________________________
\n";
}
This is the program's output:
400 Method missing
_____________________________________________________________
Agent Smith called. httpRequest is HTTP::Request=HASH(0x18443b0)
repsonse code is 400
_____________________________________________________________
Uncaught exception from user code:
Program ended normally at C:\perl-progs\login-inksco.pl line
19.
at C:\perl-progs\login-inksco.pl line 19
If you run it do you also get that stupid )*&&^%ing error? (I'm not
talking about user exception either - that's just the debugger talking)
All I EVER get out of this garbage is "400 Method Missing". I've tried
and tried, and have come to the conclusion that either PERL clients
can't use the POST method, or PERL is a useless piece of crap, or my
copy of PERL (Win32) is somehow broken.
This is driving me round the bend. Every time I try try using it to
POST I get the same, asinine error message. "400 Method Missing".
Can someone tell me what I'm doing wrong and whether I should try
another language? I like PERL, it's nice 'n' easy, like BASIC or PASCAL
but with Internet support and its widely used, but it really has
dissapointed me on this score. BTW, the GET method works just fine...
Cheers
Andy Wade