HELP! "Method Missing" error message driving me insane.

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
 
B

badnewswade

Sorry, Google has chewed up the program code a bit.

The code should read:



#!/usr/bin/perl -w
#
#

use diagnostics;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

$AgentSmith = new LWP::UserAgent;
$httpRequest = new HTTP::Request;

$address='http://badnews.inksco.com/index.php?action=login';

$thingToPost='pwd_txt';

$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";

}
 
A

A. Sinan Unur

#!/usr/bin/perl -w

use strict;

missing.
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;

Unless you know the exact effects of using & to call subroutines, and
you need those exact effects, you should call subroutines as

AgentSmith();
die "Program ended normally";

sub AgentSmith{

$output = $AgentSmith->request($httpRequest); #These three lines
actually do the request

Don't use stupid right margin comments which make it very hard for
others to copy and paste your program.
This is the program's output:


400 Method missing
....

If you run it do you also get that stupid )*&&^%ing error?


Your code fails to compile even after the wrapped right margin comments
are removed:

D:\Home\asu1\UseNet\clpmisc> perl -c z.pl
Variable "$AgentSmith" is not imported at z.pl line 25.
Global symbol "$AgentSmith" requires explicit package name at z.pl line
10.
Global symbol "$httpRequest" requires explicit package name at z.pl line
11.
....
z.pl had compilation errors.

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.

All your conclusions are wrong. It is somewhat amusing that you never
consider the possibility that you might be doing something wrong.

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...

Bad Perl ... Bad bad Perl.

Please consult the posting guidelines for this group. Please post code
others can compile and run.

Sinan
 
B

badnewswade

You're right!

$£*&*%*&ing Google Group's chewed it now!!!

It's word-wrapping the code into unusability. Thanks Google!

AAAAAAAAAARRRRRRRRRRRRRRGGGGGGGGGGGGGGHHHHHHHHHHHH!!!!!!!!!!!

p.s. Why do I need to use strict? All it seems to do is order you
around, like a sort of cyber version of a drill instructor. What's the
point? I know when my code is crap, and I know when something is very
wrong with either my appreciation of the system, or the system itsself.


I can see why you're frustrated it's the stupid way Google Groups
formats the code.

Here it is, "as nature intended". If you don't use strict it will work
and perl -c won't pass on it either. Perfect syntax (ignore the
commented out subroutine)

http://badnewswade.pwp.blueyonder.co.uk/login-inksco.pl.txt

I really really hope someone can help me with this.

ps. Sorry about the right margin comments. A habit I picked up after
years as an Assembly Language hobbyist.



A. Sinan Unur said:
#!/usr/bin/perl -w

use strict;

missing.
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;

Unless you know the exact effects of using & to call subroutines, and
you need those exact effects, you should call subroutines as

AgentSmith();
die "Program ended normally";

sub AgentSmith{

$output = $AgentSmith->request($httpRequest); #These three lines
actually do the request

Don't use stupid right margin comments which make it very hard for
others to copy and paste your program.
This is the program's output:


400 Method missing
...

If you run it do you also get that stupid )*&&^%ing error?


Your code fails to compile even after the wrapped right margin comments
are removed:

D:\Home\asu1\UseNet\clpmisc> perl -c z.pl
Variable "$AgentSmith" is not imported at z.pl line 25.
Global symbol "$AgentSmith" requires explicit package name at z.pl line
10.
Global symbol "$httpRequest" requires explicit package name at z.pl line
11.
...
z.pl had compilation errors.

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.

All your conclusions are wrong. It is somewhat amusing that you never
consider the possibility that you might be doing something wrong.

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...

Bad Perl ... Bad bad Perl.

Please consult the posting guidelines for this group. Please post code
others can compile and run.

Sinan
 
A

A. Sinan Unur

You're right!

Who is right about what? Please do not top-post.
$£*&*%*&ing Google Group's chewed it now!!!

There do exist people who are able to post properly using Google.
p.s. Why do I need to use strict?

Because it helps you:

D:\Home\asu1\UseNet\clpmisc> perl -c -Mstrict login.pl
Variable "$AgentSmith" is not imported at login.pl line 35 (#1)
(F) While "use strict" in effect, you referred to a global variable
that you apparently thought was imported from another module, because
something else of the same name (usually a subroutine) is exported by
that module. It usually means you put the wrong funny character on the
front of your variable.

None of this throwing around global variables willy nilly is productive.

I do not understand what you think sub AgentSmith is supposed to
accomplish.
sub AgentSmith{
$output = $AgentSmith->request($httpRequest);

In what magical way do you think $httpRequest was initialized???
All it seems to do is order you around, like a sort of cyber
version of a drill instructor. What's the point? I know when
my code is crap

The trouble is, you do not seem to know when your code is crap.

#!/usr/bin/perl

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

my $AgentSmith = LWP::UserAgent->new;
my $address='http://badnews.inksco.com/index.php?action=login';
my $thingToPost='c23Uj79H';

my $response = $AgentSmith->post(
$address, [
password => $thingToPost,
PHPSESSID => '96febde8d8496f962bc74ea5549ab30b'
],
);

if ($response->is_success) {
print $response->content;
} else {
warn $response->status_line, "\n";
}

__END__

D:\Home\asu1\UseNet\clpmisc> login
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1-strict.dtd'>

<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>

<head>


<title>badnewswade</title>


</head>
<body>


<a href='phpmyadmin/index.php?PHPSESSID=
96febde8d8496f962bc74ea5549ab30b'>php
MyAdmin</a>


</body>


</html>

Sinan
 
T

Tad McClellan

badnewswade said:
p.s. Why do I need to use strict?


Because it will find bugs *for you*.

All it seems to do is order you
around, like a sort of cyber version of a drill instructor. What's the
point?


It will find bugs for you.

and I know when something is very ^^^^^^^^^
wrong


Yes, but wouldn't it be nice to know _what_ is wrong?

use strict could very well tell you.
 
B

badnewswade

Well **** you then, you patronizing asshole!

Please don't post if you haven't got anything helpful to say.
 
P

Paul Lalli

Shit! He's right!

AAAAARRRRGHHHH !!!!

And you don't think that warrants a pretty massive apology on your
part? Wow. Good luck ever getting any help from this group again.

Fare thee well.

Paul Lalli
 
B

badnewswade

woops.

well, yeah , technically he's right but he's still a twat. You were
ignorant stupid newbies once too!

I must admit I can't understand this new fangled object orientation
book larnin' stuff ....
 
U

usenet

Paul said:
Fare thee well.

You're a lucky guy, Paul, to be using a real usenet reader that
supports bozo lists. Me, I'm usually stuck with Google cuz of a
firewall - so I can't killfile this idiot. Maybe I need to cobble up a
GreeseMonkey script. Hmmmm.
 
P

Paul Lalli

badnewswade said:
woops.

well, yeah , technically he's right but he's still a twat. You were
ignorant stupid newbies once too!

Being ignorant is not the same as being stupid. Being ignorant means
to not have necessary knoweldge. Being stupid means to not follow
advice that is clearly and helpfully given to you.

Everyone starts a new topic being ignorant. Only a select few start
new topics being stupid. You are apparently one of this select few.

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top