Update the runtest set.
[nethome.git] / bin / httpgetdumb
index 6ea04e0..3a78236 100755 (executable)
@@ -13,10 +13,10 @@ use constant DEFAULT_PORT=>80;
 use constant BUFFER_LENGTH=>0x1000;
 
 my %opts;
-getopts "hH",\%opts or die "getopts()";
-@ARGV==1 && $ARGV[0]=~m#^http://([^/:]+)(?::(\d+))?(/.*)$#
+getopts "xhH",\%opts or die "getopts()";
+@ARGV==1 && $ARGV[0]=~m#^http://(([^/:]+)(?::(\d+))?)(/.*)$#
                or die "Syntax: $0 [-hH] http://hostname/pathname";
-my($host,$port,$path)=($1,$2,$3);
+my($hostport,$host,$port,$path)=($1,$2,$3,$4);
 defined $port or $port=DEFAULT_PORT;
 
 my $proto=getprotobyname "tcp" or die "getprotobyname \"tcp\": $!";
@@ -25,7 +25,16 @@ my $hostaddr=gethostbyname $host or die "hostname \"$host\": $!";
 my $sockaddr=sockaddr_in $port,$hostaddr or die "sockaddr_in(".inet_ntoa($hostaddr).":$port): $!";
 connect SOCK,$sockaddr or die "connect \"$host\"(".inet_ntoa($hostaddr).":$port): $!";
 
-print SOCK ($opts{"h"} ? "HEAD" : "GET")." $path HTTP/1.0\r\nHost: $host\r\n\r\n";
+print SOCK ($opts{"h"} ? "HEAD" : "GET")." $path HTTP/1.0\r\n";
+my %header=(
+       "Host"=>$hostport,
+       "X-httpgetdumb"=>'$Id$',
+       );
+$header{"Accept"}="application/xhtml+xml" if $opts{"x"};
+while (my($key,$val)=each(%header)) {
+       print SOCK "$key: $val\r\n";
+       }
+print SOCK "\r\n";
 if ($opts{"H"}) {
        while (<STDIN>) {
                chomp;