Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent

by Cody Fendant (Friar)
on Jun 30, 2020 at 01:11 UTC ( #11118688=perlquestion: print w/replies, xml ) Need Help??

Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting this error when trying to access a URL (https).

Can't locate object method "status" via package "HTTP::Headers" at /opt/local/lib/perl5/site_perl/5.30/HTTP/Message.pm line 653.

LWP::UserAgent, HTTP::Headers and HTTP::Message are all up to date according to CPAN so I'm a bit baffled as to how to proceed.

  • Comment on 'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent
  • Download Code

Replies are listed 'Best First'.
Re: 'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent
by Fletch (Chancellor) on Jun 30, 2020 at 04:45 UTC

    Neither HTTP::Message or HTTP::Headers advertise a status method; the former delegates any method it doesn't know to the latter which is why you're getting an error. If you showed your code which is producing this error (or step back slightly further and describe what you're attempting to do) you might get more help.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: 'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent
by kcott (Bishop) on Jun 30, 2020 at 07:09 UTC

    G'day Cody Fendant,

    As already indicated by ++Fletch, if you show your code we can give a better answer. However, as you mentioned that you'd checked LWP::UserAgent, perhaps you're after its status_line method.

    $ perl -MLWP::UserAgent -E ' say LWP::UserAgent::->new()->get("http://example.com")->status_lin +e ' 200 OK

    And, of course, do bear in mind that's a complete guess.

    — Ken

Re: 'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent
by parv (Vicar) on Jun 30, 2020 at 04:08 UTC

    Are you sure that status method not be called on a requestresponse object instead?

Re: 'Can't locate object method "status" via package "HTTP::Headers"' error using LWP::UserAgent
by jcb (Priest) on Jun 30, 2020 at 22:17 UTC

    On another guess, if you are looking for the HTTP status code, you want the ->code method on HTTP::Response.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11118688]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-08-13 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (74 votes). Check out past polls.

    Notices?