function l10n_update_http_check in Localization update 7.2
Same name and namespace in other branches
- 6 l10n_update.inc \l10n_update_http_check()
- 7 l10n_update.inc \l10n_update_http_check()
Check if remote file exists and when it was last updated.
Parameters
string $url: URL of remote file.
array $headers: HTTP request headers.
Return value
object|bool Result object containing the HTTP request headers, response code, headers, data, redirect status and updated timestamp.
See also
1 call to l10n_update_http_check()
- l10n_update_batch_status_check in ./
l10n_update.batch.inc - Batch operation callback: Check status of a remote and local po file.
File
- ./
l10n_update.http.inc, line 22 - Http API for l10n updates.
Code
function l10n_update_http_check($url, array $headers = array()) {
$result = l10n_update_http_request($url, array(
'headers' => $headers,
'method' => 'HEAD',
));
if (!isset($result->error)) {
if ($result && $result->code == 200) {
$result->updated = isset($result->headers['last-modified']) ? strtotime($result->headers['last-modified']) : 0;
}
return $result;
}
else {
switch ($result->code) {
case 404:
// File not found occurs when a translation file is not yet available
// at the translation server. But also if a custom module or custom
// theme does not define the location of a translation file. By default
// the file is checked at the translation server, but it will not be
// found there.
watchdog('l10n_update', 'File not found: @uri.', array(
'@uri' => $url,
));
return TRUE;
case 0:
watchdog('l10n_update', 'Error occurred when trying to check @remote: @errormessage.', array(
'@errormessage' => $result->error,
'@remote' => $url,
), WATCHDOG_ERROR);
break;
default:
watchdog('l10n_update', 'HTTP error @errorcode occurred when trying to check @remote.', array(
'@errorcode' => $result->code,
'@remote' => $url,
), WATCHDOG_ERROR);
break;
}
}
return $result;
}