#!/usr/pkg/bin/perl # Copyright 1999 Tom Spindler. This code is public domain. use IO::Socket::INET; use Getopt::Std; getopts('P:vhp:', \%o); if (@ARGV == 0 || defined $o{h}) { print "$0 usage: $0 [-p port] [-v] URL\n -v: verbose\n"; exit; } $port = 80; ($host,$targ) = ($ARGV[0] =~ m,(?:http://)?([^/]+)(.*),); if ($host =~ m/([^:]+)(?:\:(\d+))/) { $host = $1; $port = $2; } $targ = "/" if ($targ eq ""); $port = $o{p} if defined $o{p}; $chost = $host; $cport = $port; if (defined $o{P}) { ($chost, $cport) = ($o{P} =~ m/([^:]+):?(\d+)?/); $cport = ($cport eq undef) ? 3128 : $cport; } $sock = IO::Socket::INET->new(PeerAddr => $chost, PeerPort => $cport); die "Aiee! Can't connect!\n" if (!defined $sock) ; print $sock "HEAD $targ HTTP/1.1\nHost:$host\n\n"; while (<$sock>) { if (defined $o{v}) { print; } else { print if m/^(Last-Modified|Content)/i; } last if m/^\s*$/; } close $sock;