Great module. I needed to be able to selectively warm the cache with specifically set headers, e.g. for different mobile caches

I added an additional command line switch to allow setting/overriding the CURL initialization parameters
--add-curl-params="my_overrides.php"

The additional curl params should be in this form:

function cache_warmer_get_additional_curl_params() {
  return array(
    CURLOPT_USERAGENT => 'iPad',
  );
}

This is all tested and working great. Please consider rolling into this module.

Comments

craigmc’s picture

StatusFileSize
new15.23 KB

Patch file attached here.

beebop_cj’s picture

Hey Craig.

I've been having a similar issue in which I needed to cache https pages but we have only self signed certificates on our test environments. Therefore it required a new curl option: CURLOPT_SSL_VERIFYPEER => FALSE.
The idea I had was to create a hook and each hook would return an array of cURL parameters.
The code comes right after the basic options definition:

  // cURL request basic options.
  curl_setopt_array($ch, array(
    CURLOPT_NOBODY => TRUE, // HEAD request.
    CURLOPT_TIMEOUT => $timeout,
  ));

Here is the code:

  // Offer other modules the possibility to set their own cURL options.
  foreach (module_implements('cache_warmer_curl_setopt_array') as $module) {
    $options = call_user_func($module . '_' . 'cache_warmer_curl_setopt_array');
    curl_setopt_array($ch, $options);
  }

A hook implementation would look like this:

/**
 * Implements hook_cache_warmer_curl_setopt_array().
 *
 * @return array
 *   An array with valid cURL options.
 */
function my_patches_cache_warmer_curl_setopt_array() {
  return array(
    CURLOPT_SSL_VERIFYPEER => FALSE,
  );
}

Will post the patch (maybe it's helpful for someone) in the next comment for consistency with comment-patch numbering (#2 was taken).

Cheers,
Marius

beebop_cj’s picture

StatusFileSize
new2.11 KB

Posted the patch.

Marius