chr_curl_http_request() allows options when calling it, and CHR module can override drupal_http_request, however, drupal_http_request doesn't carry options for curl options.

For the other contribute modules implement drupal_http_request(), we want to allow override and setup the CURLOPT from the variable.
The developers will be able to save the variable or assign values in settings.php. This is useful for setup a specific port in our scenario.

A sample code of overriding in the settings.php

if ($_SERVER['HTTP_HOST'] == 'example.com') {
  $port = 1234;
  // Switch to cURL http request as it allows cURL opts customization.
  $conf['drupal_http_request_function'] = 'chr_curl_http_request';

  // Set cURL resolve and port options
  $conf['chr_curl_opts_override'] = array(
    constant("CURLOPT_RESOLVE") => array("example.com:" . $port . ":127.0.0.1"),
    constant("CURLOPT_PORT") => $port,
  );
}

Override the drupal_http_request_function and set CURLOPT may affect all request.
Please beware of the $_SERVER['HTTP_HOST'] which allows the developers to only apply the proper options to the specific target host.

CommentFileSizeAuthor
#2 chr_curl_opts_override-3047556.patch622 bytesamourow

Comments

amourow created an issue. See original summary.

amourow’s picture

StatusFileSize
new622 bytes

The work is provided from the 3rd party vendor, I would like to ask them to join the ticket and give them credit if this gets committed.

amourow’s picture

Issue summary: View changes
amourow’s picture

Status: Active » Needs review