Last active
May 9, 2024 21:49
-
-
Save backroot/8d8bd272a161bec38c4bf6f4eca9594c to your computer and use it in GitHub Desktop.
Get HTTP Headers by perl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -- | |
use strict; | |
use warnings; | |
use CGI; | |
my $q = CGI->new; | |
my %headers = map { $_ => $q->http($_) } $q->http(); | |
print $q->header('text/plain'); | |
print "------------------------------\n"; | |
print "Got the following headers:\n"; | |
print "------------------------------\n"; | |
for my $header ( keys %headers ) { | |
print "$header: $headers{$header}\n"; | |
} | |
print "\n"; | |
print "------------------------------\n"; | |
print "Server Env:\n"; | |
print "------------------------------\n"; | |
for my $key ( sort ( keys ( %ENV ) ) ) { | |
print "$key: $ENV{$key}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment