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

Discussion in 'Perl Misc' started by badnewswade, Oct 7, 2005.

  1. badnewswade

    badnewswade Guest

    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
     
    badnewswade, Oct 7, 2005
    #1
    1. Advertising

  2. badnewswade

    badnewswade Guest

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

    }
     
    badnewswade, Oct 7, 2005
    #2
    1. Advertising

  3. "badnewswade" <> wrote in
    news::

    > #!/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. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 7, 2005
    #3
  4. badnewswade

    badnewswade Guest

    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 wrote:
    > "badnewswade" <> wrote in
    > news::
    >
    > > #!/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. Sinan Unur <>
    > (reverse each component and remove .invalid for email address)
    >
    > comp.lang.perl.misc guidelines on the WWW:
    > http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    badnewswade, Oct 7, 2005
    #4
  5. "badnewswade" <> wrote in
    news::

    > 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

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 7, 2005
    #5
  6. badnewswade <> wrote:

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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Oct 7, 2005
    #6
  7. badnewswade

    badnewswade Guest

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

    Please don't post if you haven't got anything helpful to say.
     
    badnewswade, Oct 7, 2005
    #7
  8. badnewswade

    badnewswade Guest

    Shit! He's right!

    AAAAARRRRGHHHH !!!!
     
    badnewswade, Oct 7, 2005
    #8
  9. badnewswade

    Paul Lalli Guest

    badnewswade wrote:
    > > Well **** you then, you patronizing asshole!
    > >
    > > Please don't post if you haven't got anything helpful to say.


    > 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
     
    Paul Lalli, Oct 7, 2005
    #9
  10. badnewswade

    badnewswade Guest

    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 ....
     
    badnewswade, Oct 7, 2005
    #10
  11. badnewswade <> wrote:

    > Shit! He's right!



    So where is your apology then?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Oct 7, 2005
    #11
  12. badnewswade

    Guest

    Paul Lalli wrote:
    > 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.
     
    , Oct 8, 2005
    #12
  13. badnewswade

    Paul Lalli Guest

    badnewswade wrote:
    > 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
     
    Paul Lalli, Oct 9, 2005
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Black

    Insane server control style problem...

    Jack Black, Apr 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    376
    DoesDotNet
    Apr 28, 2005
  2. Replies:
    2
    Views:
    435
  3. chris kramer
    Replies:
    3
    Views:
    409
    Victor Bazarov
    Jan 25, 2004
  4. Edward Grefenstette

    Help with Tkinter on OS X --- driving me insane!

    Edward Grefenstette, May 17, 2009, in forum: Python
    Replies:
    8
    Views:
    465
    Dennis Lee Bieber
    May 18, 2009
  5. MissKirin

    Help me please before I go insane

    MissKirin, Feb 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    140
    Sarmad Aljazrawi
    Feb 29, 2004
Loading...

Share This Page