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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | chr_curl_opts_override-3047556.patch | 622 bytes | amourow |
Comments
Comment #2
amourowThe 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.
Comment #3
amourowComment #4
amourow