summaryrefslogtreecommitdiff
path: root/APACHE_1_3_42/src/test/vhtest/bin/vhget
diff options
context:
space:
mode:
authorColm MacCarthaigh <colm@apache.org>2010-01-08 11:45:43 +0000
committerColm MacCarthaigh <colm@apache.org>2010-01-08 11:45:43 +0000
commit396931c93e46f5d130f0df7044a9c0e63fd12ebd (patch)
tree9ff5247f604985caa9581ebe4bfa6aa5164db5ce /APACHE_1_3_42/src/test/vhtest/bin/vhget
parent7d344b579813528064a6711a91f675b7f47e4926 (diff)
downloadhttpd-800595eceb63d691618214f91844d445062422e2.tar.gz
Tag 1.3.421.3
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/tags/1.3@897175 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'APACHE_1_3_42/src/test/vhtest/bin/vhget')
-rwxr-xr-xAPACHE_1_3_42/src/test/vhtest/bin/vhget74
1 files changed, 74 insertions, 0 deletions
diff --git a/APACHE_1_3_42/src/test/vhtest/bin/vhget b/APACHE_1_3_42/src/test/vhtest/bin/vhget
new file mode 100755
index 0000000000..62f3148c02
--- /dev/null
+++ b/APACHE_1_3_42/src/test/vhtest/bin/vhget
@@ -0,0 +1,74 @@
+#!/usr/bin/perl -w
+
+require 5.002;
+use strict;
+use Socket;
+
+# vhget ipaddr port hostheader absurihost expect
+
+$#ARGV == 4 || die "usage: $0 ipaddr port hostheader absurihost expect\n";
+
+my ($remote,$port, $iaddr, $paddr, $proto, $line);
+
+my ($hostheader, $expect, $absurihost);
+
+($remote, $port, $hostheader, $absurihost, $expect) = @ARGV;
+if ($absurihost ne '') {
+ $absurihost = "http://$absurihost";
+}
+
+printf "%-20s %-20s %-20s %-15s: ", "$remote:$port", "'$hostheader'", "'$absurihost'", "'$expect'";
+
+if ($port =~ /\D/) {
+ $port = getservbyname($port, 'tcp');
+}
+die "No port" unless $port;
+$iaddr = inet_aton($remote) || die "no host: $remote";
+$paddr = sockaddr_in($port, $iaddr);
+$proto = getprotobyname('tcp');
+socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
+connect(SOCK, $paddr) || die "connect: $!";
+
+my $oldfh = select(SOCK); $| = 1; select($oldfh);
+
+$proto = ($absurihost ne '') ? "HTTP/1.1" : "HTTP/1.0";
+
+if ($hostheader ne '') {
+ print SOCK <<EOR;
+GET $absurihost/vhost.txt $proto\r
+Host: $hostheader\r
+Connection: close\r
+\r
+EOR
+} else {
+ print SOCK <<EOR;
+GET $absurihost/vhost.txt $proto\r
+Connection: close\r
+\r
+EOR
+}
+
+defined($line = <SOCK>) || die "error reading response: $!\n";
+
+($line =~ m#^HTTP/1\.1 200#) || die "HTTP error: $line\n";
+
+while (defined($line = <SOCK>)) {
+ last if $line =~ /^\r?$/;
+}
+
+defined($line = <SOCK>) || die "error reading response: $!\n";
+
+chomp($line);
+
+my $death = "$remote:$port with "
+ . ( $hostheader eq '' ? "no Host:" : "Host: $hostheader" )
+ . ( $absurihost eq '' ? " no absuri" : " and absuri $absurihost" )
+ . " expected $expect, but got $line\n";
+if ($line eq $expect) {
+ print "passed\n";
+} else {
+ print "failed, got '$line'\n";
+}
+
+close (SOCK) || die "close: $!";
+exit;