You are here

function http_request_use_curl in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 libraries/http_request.inc \http_request_use_curl()
  2. 6 libraries/http_request.inc \http_request_use_curl()
  3. 7 libraries/http_request.inc \http_request_use_curl()

Decides if it's possible to use cURL or not.

Return value

bool TRUE if cURL may be used, FALSE otherwise.

1 call to http_request_use_curl()
feeds_http_request in libraries/http_request.inc
Get the content from the given URL.

File

libraries/http_request.inc, line 419
Download via HTTP.

Code

function http_request_use_curl() {

  // Allow site administrators to choose to not use cURL.
  if (variable_get('feeds_never_use_curl', FALSE)) {
    return FALSE;
  }

  // Check that the PHP cURL extension has been enabled.
  if (!extension_loaded('curl')) {
    return FALSE;
  }

  // cURL below PHP 5.6.0 must not have open_basedir or safe_mode enabled.
  if (version_compare(PHP_VERSION, '5.6.0', '<')) {

    // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
    return !ini_get('safe_mode') && !ini_get('open_basedir');
  }

  // cURL in PHP 5.6.0 and above re-enables CURLOPT_FOLLOWLOCATION with
  // open_basedir so there is no need to check for this.
  return TRUE;
}