Hi,
i tried to use this module to improve stage_file_proxy, but somehow i can't figure how to get the raw data of a request.
Thought i should use the callback functionality, but $data is always just "1"
Also, the callback is called but the return value never reaches the main function.
function stage_file_proxy_cb($data) {
watchdog('stage_file_proxy', "data: %data", array("%data" => print_r($data),));
return array('something' => "here");
}
function _stage_file_proxy_fetch_httprl($url, $file_dir, $relative_path) {
$x = new stdClass();
$options = array(
//'method' => 'HEAD',
'callback' => array(
array(
'function' => 'stage_file_proxy_cb',
'return' => &$x,
),
)
);
httprl_request($url, $options);
$request = httprl_send_request();
watchdog("stage_file_proxy", "fetching with httprl: %url <br /> data: %data <br /> callback: %callback", array("%url" => $url, "%data" => print_r($request), "%callback" => print_r($x)), WATCHDOG_DEBUG);
file_put_contents($file_dir . '/' . $relative_path, $request);
return TRUE;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | httprl-1889006-3-minor-adjustments-for-readme-examples.patch | 2.51 KB | mikeytown2 |
| #2 | httprl-1889006-2-save-file-example.patch | 4.36 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 commentedFor the most part httprl has the same API as core's drupal_http_request(). So using httprl or core will have very similar looking code. The main difference between core and httprl is httprl returns an array of URLs.
Callbacks are mainly useful with parallel requests.
Comment #2
mikeytown2 commentedThe following patch has been committed.
Comment #3
mikeytown2 commentedChanged a couple more things in the readme file.