Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by Cody Fendant (Hermit)
on Jun 30, 2020 at 01:11 UTC ( [id://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 (Bishop) 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 (Archbishop) 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 (Parson) 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 (Parson) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-18 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found