You are here

function advagg_install_test_async_stream in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.install \advagg_install_test_async_stream()

Test if STREAM_CLIENT_ASYNC_CONNECT can be used.

1 call to advagg_install_test_async_stream()
advagg_check_missing_handler in ./advagg.install
Check to see if the CSS/JS generator is working.

File

./advagg.install, line 563
Handles Advanced Aggregation installation and upgrade tasks.

Code

function advagg_install_test_async_stream() {
  global $conf, $base_path;
  if (!function_exists('stream_socket_client') || !function_exists('stream_select')) {
    return FALSE;
  }
  $advagg_async_socket_connect = variable_get('advagg_async_socket_connect', ADVAGG_ASYNC_SOCKET_CONNECT);

  // Build test request.
  $url = _advagg_build_url();
  $headers = array(
    'Host' => $_SERVER['HTTP_HOST'],
    'Connection' => 'close',
  );

  // Request file.
  $conf['advagg_async_socket_connect'] = TRUE;
  advagg_async_connect_http_request($url, array(
    'headers' => $headers,
  ));

  // Send Request off.
  $good = advagg_async_send_http_request();
  if ($good && !$advagg_async_socket_connect) {
    variable_set('advagg_async_socket_connect', TRUE);
    return TRUE;
  }
  else {
    $conf['advagg_async_socket_connect'] = FALSE;
  }
}