You are here

function _varnish_execute_command in Varnish 6

Same name and namespace in other branches
  1. 8 varnish.module \_varnish_execute_command()
  2. 7 varnish.module \_varnish_execute_command()
1 call to _varnish_execute_command()
_varnish_terminal_run in ./varnish.module
Helper function that sends commands to Varnish

File

./varnish.module, line 345
varnish.module Provide drupal hooks for integration with the Varnish control layer.

Code

function _varnish_execute_command($client, $command) {

  // Send command and get response.
  $result = socket_write($client, "{$command}\n");
  $status = _varnish_read_socket($client);
  if ($status['code'] != 200) {
    watchdog('varnish', 'Received status code @code running %command. Full response text: %error', array(
      '@code' => $status['code'],
      '%command' => $command,
      '%error' => $status['msg'],
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  else {

    // successful connection
    return $status;
  }
}