Last active
February 4, 2016 01:27
-
-
Save wakaba/f89aa0ba4042d2a227f1 to your computer and use it in GitHub Desktop.
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
use strict; | |
use warnings; | |
$ENV{LANG} = 'C'; | |
my @host = qw( | |
www.google.com | |
mail.google.com | |
github.com | |
gist.github.com | |
gist.githubusercontent.com | |
httpd.apache.org | |
soulsphere.org | |
whatwg.org | |
dom.spec.whatwg.org | |
promisesaplus.com | |
www.facebook.com | |
helloworld.letsencrypt.org | |
www.hatena.ne.jp | |
www.hatena.com | |
hatena.g.hatena.ne.jp | |
roomhub.jp | |
example.herokuapp.com | |
); | |
sub dataurl ($) { | |
my $data = shift; | |
$data =~ s/([^A-Za-z0-9_])/sprintf '%%%02X', ord $1/ge; | |
return 'data:,'.$data; | |
} # dataurl | |
print q{<!DOCTYPE HTML><title>HTTP+TLS accesses</title> | |
<style>.PASS { background: green; color: white } | |
.FAIL { background: red; color: white }</style> | |
<table><thead><tr><th>Host<th>wget<th>curl<tbody>}; | |
for my $host (@host) { | |
warn "$host...\n"; | |
print qq{<tr><th>$host}; | |
{ | |
my $result = `wget -O /tmp/test.html https://$host/ 2>&1`; | |
if ($? >> 8) { | |
print q{<td class=FAIL><a href="}.dataurl($result).q{">FAIL</a>}; | |
} else { | |
print q{<td class=PASS>PASS}; | |
} | |
} | |
{ | |
my $result = `curl https://$host/ 2>&1 > /dev/null`; | |
if ($? >> 8) { | |
print q{<td class=FAIL><a href="}.dataurl($result).q{">FAIL</a>}; | |
} else { | |
print q{<td class=PASS>PASS}; | |
} | |
} | |
} | |
print q{<tbody><tr><th>Version}; | |
{ | |
my $version = `wget --version`; | |
my $ver = '???'; | |
if ($version =~ /GNU Wget (.+) built on /) { | |
$ver = $1; | |
} | |
print q{<td><a href="} . dataurl ($version) . q{">}.$ver.q{</a>}; | |
} | |
{ | |
my $version = `curl --version`; | |
my $ver = '???'; | |
if ($version =~ /^curl (\S+)/) { | |
$ver = $1; | |
} | |
print q{<td><a href="} . dataurl ($version) . q{">}.$ver.q{</a>}; | |
} | |
print q{</table>}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment