#!/usr/bin/perl -w use IO::Socket; unless (@ARGV) { die "usage: $0 URL\n" } $EOL = "\015\012"; $BLANK = $EOL x 2; $sep = (@ARGV > 1) ? "-------------------\n" : ""; foreach $url ( @ARGV ) { unless($url =~ m{^http://(.*?)/(.*)$}) { print "$0: invalid url: $url\n"; next } $host = $1; $rest = $2; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)", ); unless ($remote) { die "Cannot connect to http daemon on $host\n" } $remote->autoflush(1); print $remote "GET /$rest HTTP/1.1". $EOL . "Host: $host" . $BLANK; while ( <$remote> ) { print } print "\n$sep"; close $remote; }