#!/usr/local/bin/perl # # Netprog spring 98 # # test client used for grading proxy web servers # give this perl script the address of the server as a hostname and port number # # This client reads a script that contains commands used to test # project 1 submissions. Supported commands are: # # CONNECT : establish a connection to the proxy server # (forces a close as well) # SEND string : send the specified string # CLOSE : close the TCP socket the proxy # READLINE : read one line from proxy and toss away # READALL : read from proxy until EOF (tossing away) # SAVEALL file : read from proxy until EOF and save in file # SAVECONTENT : skip headers and save content in file # ECHOLINE : read one line from proxy and print # ECHOALL : read from proxy until EOF and print # EXPECT file : read from proxy until EOF and compare to a file # EXPECTCONTENT file : read from proxy, until EOF and compare to a file # tosses headers before comparing # PRINT string : print the string to STDOUT # EVAL string : eval the perl commandprint the string to STDOUT require 5.002; use strict; #use sigtrap; use Socket; my %commands = ( "close",1, "connect",1, "echoall",1, "echoline",1, "expect",1, "expectcontent",1, "print",1, "readall",1, "readline",1, "send",1, "saveall",1, "savecontent",1, "eval",1, "sleep",1); select STDOUT; $|=1; # collect command line parameters my $hostname = shift || die "No host specified!"; my $port = shift || die "No port specified!"; my $script = shift || die "No script specified"; my($command,@tmp,$perlcom); open(SCRIPT,"$script") || die $!; # process commands from the script file while (