diff options
author | Michael Adam <obnox@samba.org> | 2009-10-12 02:01:25 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-10-12 02:01:25 +0200 |
commit | cbaa4b9fd2f0b4f8a6cf70a1616889d5d46610e2 (patch) | |
tree | f2fda73106856e8722aec81c2a5a992d374897ea /tests/scripts | |
parent | e793a729f65055c0c1872850bf49a83ff30ec49e (diff) |
tests:webclient: add option to send a request entity (body)
Diffstat (limited to 'tests/scripts')
-rwxr-xr-x | tests/scripts/webclient.pl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/scripts/webclient.pl b/tests/scripts/webclient.pl index 8d1c988..25c0fb7 100755 --- a/tests/scripts/webclient.pl +++ b/tests/scripts/webclient.pl @@ -34,6 +34,7 @@ my $http_version = "1.0"; my $method = "GET"; my $dry_run = 0; my $help = 0; +my $entity = undef; my $default_port = "80"; my $port = $default_port; @@ -42,7 +43,8 @@ sub process_options() { my $result = GetOptions("help|?" => \$help, "http-version=s" => \$http_version, "method=s" => \$method, - "dry-run" => \$dry_run); + "dry-run" => \$dry_run, + "entity=s" => \$entity); die "Error reading cmdline options! $!" unless $result; pod2usage(1) if $help; @@ -51,9 +53,9 @@ sub process_options() { } -sub build_request($$$$$) +sub build_request($$$$$$) { - my ( $host, $port, $version, $method, $document ) = @_; + my ( $host, $port, $version, $method, $document, $entity ) = @_; my $request = ""; $method = uc($method); @@ -77,6 +79,10 @@ sub build_request($$$$$) $request .= $EOL; + if ($entity) { + $request .= $entity; + } + return $request; } @@ -97,7 +103,7 @@ if ($host =~ /^([^:]+):(.*)/) { } foreach my $document (@ARGV) { - my $request = build_request($host, $port, $http_version, $method, $document); + my $request = build_request($host, $port, $http_version, $method, $document, $entity); if ($dry_run) { print $request; exit(0); @@ -151,6 +157,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<--entity> + +Add the provided string as entity (i.e. body) to the request. + =item B<--dry-run> Don't actually connect to the server but print the request that would be sent. |