From dbd2228456daff61fa53c98d285ec3f39706fd3c Mon Sep 17 00:00:00 2001 From: des Date: Wed, 8 Aug 2007 10:58:17 +0000 Subject: [PATCH] Improve request generation. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1812 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- .../regress/lib/Varnish/Test/Case.pm | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/varnish-tools/regress/lib/Varnish/Test/Case.pm b/varnish-tools/regress/lib/Varnish/Test/Case.pm index 1293b792..b7cee4da 100644 --- a/varnish-tools/regress/lib/Varnish/Test/Case.pm +++ b/varnish-tools/regress/lib/Varnish/Test/Case.pm @@ -197,7 +197,7 @@ sub ev_server_request($$$$) { my ($self, $server, $connection, $request) = @_; no strict 'refs'; - my $method = $request->method(); + my $method = lc($request->method()); my $handler; if ($self->can("server_$method")) { $handler = ref($self) . "::server_$method"; @@ -228,15 +228,26 @@ sub ev_server_request($$$$) { sub request($$$$;$$) { my ($self, $client, $method, $uri, $header, $content) = @_; - my $req = HTTP::Request->new($method, $uri, $header, $content); + my $req = HTTP::Request->new($method, $uri, $header); $req->protocol('HTTP/1.1'); + $req->header('Host' => 'varnish.example.com') + unless $req->header('Host'); + $req->header('User-Agent' => ref($self)) + unless $req->header('User-Agent'); + if (defined($content)) { + $req->header('Content-Type' => 'text/plain') + unless ($req->header('Content-Type')); + $req->header('Content-Length' => length($content)) + unless ($req->header('Content-Length')); + $req->content($content); + } $client->send_request($req, 2); my ($ev, $resp) = $self->run_loop('ev_client_response', 'ev_client_timeout'); - die "Internal error\n" - unless $resp && ref($resp) && $resp->isa('HTTP::Response'); die "Client time-out before receiving a (complete) response\n" if $ev eq 'ev_client_timeout'; + die "Internal error\n" + unless $resp && ref($resp) && $resp->isa('HTTP::Response'); die "No X-Varnish header\n" unless $resp->header('X-Varnish'); $resp->request($req); @@ -260,8 +271,6 @@ sub post($$$;$$) { $header = [] unless defined($header); - push(@{$header}, 'content-length', length($body)) - if defined($body); return $self->request($client, 'POST', $uri, $header, $body); } -- 2.39.5