function background_process_build_request in Background Process 7
Same name and namespace in other branches
- 8 background_process.module \background_process_build_request()
- 6 background_process.module \background_process_build_request()
- 7.2 background_process.http.inc \background_process_build_request()
Build url and headers for http request.
Parameters
string $url: Relative url for the request
string $service_hostname: Name of service host, e.g. 'default'
Return value
array array(url, headers)
4 calls to background_process_build_request()
- BackgroundProcess::dispatch in ./
BackgroundProcess.class.php - background_process_ass_auto_unlock in background_process_ass/
background_process_ass.module - Unlock locked processes that aren't really running.
- background_process_ass_get_server_status in background_process_ass/
background_process_ass.module - Get apache extended server status.
- background_process_determine_default_service_host in ./
background_process.module - Determine host for current installation.
File
- ./
background_process.module, line 1002
Code
function background_process_build_request($url, $service_hostname = NULL, $options = array()) {
$service_hosts = background_process_get_service_hosts();
if (!$service_hostname || empty($service_hosts[$service_hostname])) {
$service_hostname = 'default';
}
$service_host = $service_hosts[$service_hostname];
$options += array(
'absolute' => TRUE,
'base_url' => $service_host['base_url'],
);
$url = url($url, $options);
$parsed = parse_url($url);
$host = !empty($service_host['http_host']) ? $service_host['http_host'] : (isset($parsed['host']) ? isset($parsed['port']) ? $parsed['host'] . ':' . $parsed['port'] : $parsed['host'] : NULL);
$headers = _background_process_request_headers();
$headers = _background_process_filter_headers($headers);
$headers['User-Agent'] = variable_get('background_process_user_agent', 'Drupal (+http://drupal.org/)');
$headers['Host'] = $host;
$headers['Connection'] = 'close';
if (isset($parsed['user'])) {
$headers['Authorization'] = 'Basic ' . base64_encode($parsed['user'] . ':' . $parsed['pass']);
}
return array(
$url,
$headers,
);
}