This is a module intended for developers, as it provides just one API to call: chr_curl_http_request() (use curl_http_request() for versions 1.5 and earlier).

The function chr_curl_http_request() is an alternative implementation of Drupal core function drupal_http_request() using cURL.
The function intends to be backwards compatible with drupal_http_request(), by accepting the same parameters in the same form and by returning the response in the same format.

Debug HTTP requests (v1.6 and higher)

View dpm() print-outs of HTTP requests/response objects by enabling Devel and the debug mode in the cURL HTTP Request administrative section.

Proxy support

cURL HTTP request does provide some extra features, though: it allows for requests to be sent via proxy, whether they are HTTP or HTTPS request. It can even support different proxies for HTTP and HTTPS. Basic proxy authentication via username and password is also supported as well as an exception list of hostnames not to be contacted via proxy.

Sample proxy settings

An example of the proxy configuration that you must add to your settings.php in order to have proxy support in your request via curl_http_request():

/**
 * External access proxy settings:
 *
 * If your site must access the Internet via a web proxy then you can enter
 * the proxy settings here. Currently only basic authentication is supported
 * by using the username and password variables. The 'exceptions' variable
 * is an array of host names to be accessed directly, not via proxy.
 */

// As of version 1.7, the following settings is no longer mandatory. 
// When not specified, 'chr' will leverage Drupal proxy settings 
// (see http://git.io/vU8Af) and use them for both HTTP and HTTPS.
$conf['http_proxy'] = array(
  'server' => 'your.proxy.com',
  'port' => '8080',
  'username' => 'user',
  'password' => 'pass',
  'exceptions' => array('localhost'),
);
// As of version 1.7, the following it's assumed by default and
// you can omit this line.  If you haven't set 'http_proxy', 'chr' will
// fall back on Drupal proxy settings and use the same settings 
// for both HTTP and HTTPS.
$conf['https_proxy'] = $conf['http_proxy'];

Drupal 7 specific features

Automatic override of drupal_http_request() (v1.6 and higher)

As of Drupal 7.21 you can register an alternative HTTP request function. Using the administrative section admin/config/services/chr you can set chr_curl_http_request() as the default method.

Compatibility with the RESTClient module

RESTClient depends on chr to make HTTP requests for REST services.

Sponsorship

This module was partially sponsored by Artetecha Ltd. and Coldfront Labs Inc.

Maintainers

  1. Vincenzo
  2. minorOffense
Supporting organizations: 
Development time and support

Project information

Releases