Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: HTTP Headers Using WWW::Mechanize

by merlyn (Sage)
on Jan 31, 2005 at 19:48 UTC ( [id://426708]=note: print w/replies, xml ) Need Help??


in reply to HTTP Headers Using WWW::Mechanize

What's wrong with:
$mech->response->headers->as_string
?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: HTTP Headers Using WWW::Mechanize
by Limbic~Region (Chancellor) on Jan 31, 2005 at 20:08 UTC
    merlyn,
    What's wrong with: $mech->response->headers->as_string?

    Nothing, except it solves a problem other than the one I was going after (see Description).

    First, the docs for WWW::Mechanize leave a little to be desired as far as getting at the headers in the first place. You have to know that the HTTP::Response object returned by the response() method has what you are looking for.

    Second, the intention by accessing them by key was just to get the value you wanted as per the Description. In this particular case, water was after the p3p key. Of course you could parse the results of the as_string method, but why?

    Cheers - L~R

      Patches welcome. If something's unclear, please send me updates to the doc that expand on it. It's hard for me, as the author, to know what people need to know, or if it's not as clear as should be.

      xoxo,
      Andy

        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.

        Cheers - L~R

        So, nobody has done the patch to the documentation still.
        I've had struggle with the same thing and didn't know, how to get the headers, until i got to this post, because the documentation doesn't mention anything about it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://426708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found