function background_process_build_request in Background Process 7.2
Same name and namespace in other branches
- 8 background_process.module \background_process_build_request()
- 6 background_process.module \background_process_build_request()
- 7 background_process.module \background_process_build_request()
Build url and headers for http request
Parameters
$url: Relative url for the request
$service_hostname: Name of service host, e.g. 'default'
Return value
array array(url, headers)
3 calls to background_process_build_request()
- 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_dispatcher_http in ./
background_process.dispatchers.inc - Dispatcher for HTTP
File
- ./
background_process.http.inc, line 16 - This contains the HTTP functions for Background Process.
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']) ? $parsed['host'] : NULL);
$headers = _background_process_request_headers();
$headers = _background_process_filter_headers($headers);
$headers['Host'] = $host;
$headers['Connection'] = 'Close';
if (isset($parsed['user'])) {
$headers['Authorization'] = 'Basic ' . base64_encode($parsed['user'] . ':' . $parsed['pass']);
}
return array(
$url,
$headers,
);
}