Created
May 10, 2010 14:30
-
-
Save aanoaa/396095 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use IO::Socket; | |
use Time::HiRes qw[gettimeofday tv_interval]; | |
my $time=[gettimeofday()]; | |
unless(@ARGV>1) { | |
die "usage: $0 host port [document+]\n"; | |
} | |
my $host=shift(@ARGV); | |
my $port=shift(@ARGV); | |
foreach my $document (@ARGV) { | |
my $remote=IO::Socket::INET->new( | |
Proto=>"tcp", | |
PeerAddr=>$host, | |
PeerPort=>$port, | |
); | |
unless($remote) { | |
die "cannot connect to http daemon on $host\n"; | |
} | |
$remote->autoflush(1); | |
print $remote "GET $document HTTP/1.0\n\n"; | |
#print $remote "OPTIONS $document HTTP/1.0\n\n"; | |
#print $remote "HEAD $document HTTP/1.0\n\n"; | |
while(<$remote>) { print } | |
#print "elapsed time: ".&elapsed_time($time)."\n"; | |
close $remote; | |
} | |
exit; | |
sub elapsed_time { | |
my $time=shift; | |
return tv_interval($time)*1000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment