Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks,
I have been using LWP to pull information from the web. I am able to save files and dump the headers for the files being pulled, but I wanted to know if anyone can tell me how to dump raw headers rather than using the following:

$ua = LWP::UserAgent->new(keep_alive => 1, timeout => 600);
$ua->protocols_allowed( 'ftp', 'http', 'https' );
$response = $ua->get($request);
$headers=$reponse->headers->as_string;

Basically, I just want to dump the headers to a file in all their glory. I want all parts, including non-strings, so this is why I was wondering if there is another way it can be done.

Thanks in advance for any advice.

Replies are listed 'Best First'.
Re: LWP raw header dump
by kubrat (Scribe) on Sep 25, 2009 at 13:49 UTC

    I beleive that $reponse->headers->as_string; does give you all the headers when the protocol is http(s). I don't think you can have non-strings in http headers unless encoded it is a text based protocol afterall.

    Don't know what headers->as_string; returns when the protocol is ftp.