You are here

function httprl_set_connection_flag in HTTP Parallel Request & Threading Library 6

Same name and namespace in other branches
  1. 7 httprl.module \httprl_set_connection_flag()

Select which connect flags to use in stream_socket_client().

Parameters

array &$options: Array containing options.

array $uri: Array from parse_url().

Return value

int STREAM_CLIENT_CONNECT or STREAM_CLIENT_ASYNC_CONNECT|STREAM_CLIENT_CONNECT.

1 call to httprl_set_connection_flag()
httprl_request in ./httprl.module
Queue up a HTTP request in httprl_send_request.

File

./httprl.module, line 712
HTTP Parallel Request Library module.

Code

function httprl_set_connection_flag(&$options, $uri) {
  $flags = STREAM_CLIENT_CONNECT;

  // Set connection flag.
  if ($options['async_connect']) {

    // Workaround for PHP bug with STREAM_CLIENT_ASYNC_CONNECT and SSL
    // https://bugs.php.net/bug.php?id=48182 - Fixed in PHP 5.2.11 and 5.3.1
    if ($uri['scheme'] == 'https' && (version_compare(PHP_VERSION, '5.2.11', '<') || version_compare(PHP_VERSION, '5.3.0', '='))) {
      $options['async_connect'] = FALSE;
    }
    else {
      $flags = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT;
    }
  }
  return $flags;
}