Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: HTTP Headers Using WWW::Mechanize

by Limbic~Region (Chancellor)
on Feb 01, 2005 at 09:19 UTC ( [id://426900]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^3: HTTP Headers Using WWW::Mechanize
in thread HTTP Headers Using WWW::Mechanize

petdance,
It isn't specifically that something is unclear. It is that WWW::Mechanize is built on a lot of prior art.

There isn't a succintly way to say that WWW::Mechanize is a subclass of LWP::UserAgent which uses HTTP::Response which is a subclass of HTTP::Message which uses HTTP::Headers so while there isn't a direct method of listing the header keys or there values, you can still get to them.

Even if that could be said concisely, it would only address the headers issue. The underlying issue is that to get the absolute most out of a module like WWW::Mechanize, the user needs to spend some time understanding the prior art and how it is being used. As such, my patch is just an addition to the FAQ. While I have emailed it to you, I am including a copy here as well.

--- FAQ.pod 2004-06-25 23:10:45.000000000 -0400 +++ FAQ.new 2005-02-01 09:18:30.865078400 -0500 @@ -49,6 +49,19 @@ my @frame_links = $mech->find_link( tag => "frame" ); +=head2 How do I get a list of HTTP headers and their values? + +All L<HTTP::Headers> methods work on a L<HTTP::Response> object which + is +returned by the I<get()>, I<reload()>, I<response()/res()>, I<click() +>, +I<submit_form()>, and I<request()> methods. + + my $mech = WWW::Mechanize->new( autocheck => 1 ); + $mech->get( 'http://my.site.com' ); + my $res = $mech->response(); + for my $key ( $response->header_field_names() ) { + print $key, " : ", $response->header( $key ), "\n"; + } + =head1 Why doesn't this work? =head2 Why don't https:// URLs work?

Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://426900]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.