Skip to content

Instantly share code, notes, and snippets.

@ozuma
Created May 9, 2013 13:58
Show Gist options
  • Save ozuma/5547584 to your computer and use it in GitHub Desktop.
Save ozuma/5547584 to your computer and use it in GitHub Desktop.
Get HTTP Response Headers as string.
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0");
my $req = HTTP::Request->new(GET => 'http://www.example.com/');
my $res = $ua->simple_request($req);
print $res->headers_as_string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment