diff options
author | Michael Adam <obnox@samba.org> | 2009-09-16 22:34:35 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-09-16 22:35:35 +0200 |
commit | b7d9256a7a673ec38da2448d9de879bfd7d1e9e4 (patch) | |
tree | 1cab10506ab6a890901c612d7ecdc4c0546bcb13 /tests | |
parent | 4ef79011155d7c826f33f210196b587cc045c74f (diff) | |
download | tinyproxy-b7d9256a7a673ec38da2448d9de879bfd7d1e9e4.tar.gz tinyproxy-b7d9256a7a673ec38da2448d9de879bfd7d1e9e4.zip |
tests:webclient: add a --dry-run mode that prints the request to stdout
and does not connect to the server at all.
Michael
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/scripts/webclient.pl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/scripts/webclient.pl b/tests/scripts/webclient.pl index f76dbd9..84d8790 100755 --- a/tests/scripts/webclient.pl +++ b/tests/scripts/webclient.pl @@ -32,6 +32,7 @@ my $user_agent = "$NAME/$VERSION"; my $user_agent_header = "User-Agent: $user_agent$EOL"; my $http_version = 1.0; my $method = "GET"; +my $dry_run = 0; my $help = 0; my $default_port = "80"; @@ -40,7 +41,8 @@ my $port = $default_port; sub process_options() { my $result = GetOptions("help|?" => \$help, "http-version=s" => \$http_version, - "method=s" => \$method); + "method=s" => \$method, + "dry-run" => \$dry_run); die "Error reading cmdline options! $!" unless $result; pod2usage(1) if $help; @@ -99,6 +101,12 @@ if ($host =~ /^([^:]+):(.*)/) { } foreach my $document (@ARGV) { + my $request = build_request($host, $port, $http_version, $method, $document); + if ($dry_run) { + print $request; + exit(0); + } + my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, @@ -110,7 +118,7 @@ foreach my $document (@ARGV) { $remote->autoflush(1); - print $remote build_request($host, $port, $http_version, $method, $document); + print $remote $request; while (<$remote>) { print; @@ -147,6 +155,10 @@ Specify the HTTP protocol version to use (0.9, 1.0, 1.1). Default is 1.0. Specify the HTTP request method ('GET', 'CONNECT', ...). Default is 'GET'. +=item B<--dry-run> + +Don't actually connect to the server but print the request that would be sent. + =back =head1 DESCRIPTION |