]> err.no Git - varnish/commitdiff
Let send_command() take care of quoting and assembling the command.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 13 Jun 2007 11:12:07 +0000 (11:12 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 13 Jun 2007 11:12:07 +0000 (11:12 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1511 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-tools/regress/lib/Varnish/Test/Varnish.pm

index 8873f6aa6c8cdb00cff4a78fad5613cae194df2f..d2fb567419ef954733523428be0bc9cd66a6213b 100644 (file)
@@ -124,12 +124,20 @@ sub backend_block($$) {
                   $name, split(':', $self->{'engine'}->{'config'}->{'server_address'}));
 }
 
-sub send_command($$) {
-    my ($self, $command) = @_;
+sub send_command($@) {
+    my ($self, @args) = @_;
     croak 'not ready' if $self->{'state'} eq 'init';
     croak sprintf('busy awaiting earlier command (%s)', $self->{'pending'})
       if defined $self->{'pending'};
 
+    foreach (@args) {
+       if (m/[\s\"\n]/) {
+           s/\n/\\n/g;
+           s/\"/\\\"/g;
+           s/^(.*)$/"$1"/g;
+       }
+    }
+    my $command = join(' ', @args);
     $self->{'mux'}->write($self->{'stdin'}, $command . "\n");
     $self->{'pending'} = $command;
 }
@@ -137,10 +145,13 @@ sub send_command($$) {
 sub send_vcl($$$) {
     my ($self, $config, $vcl) = @_;
 
-    $vcl =~ s/\n/ /g;
-    $vcl =~ s/"/\\"/g;
+    $self->send_command('vcl.inline', $config, $vcl);
+}
+
+sub use_vcl($$) {
+    my ($self, $config) = @_;
 
-    $self->send_command(sprintf('vcl.inline %s "%s"', $config, $vcl));
+    $self->send_command('vcl.use', $config);
 }
 
 sub start_child($) {
@@ -193,7 +204,7 @@ sub mux_input($$$$) {
     }
 
     $self->{'engine'}->ev_varnish_command_ok(delete $self->{'pending'})
-      if ($$data =~ /^200 0/ and $self->{'pending'});
+       if ($$data =~ /^200 0/ and $self->{'pending'});
 
     $$data = '';
 }