OC_Response: add setExpiresHeader function

This commit is contained in:
Bart Visscher 2012-02-12 20:38:28 +01:00
parent 45bb6f5fd4
commit 125cf79a37
2 changed files with 13 additions and 3 deletions

View File

@ -27,9 +27,7 @@ OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
function getStandardImage(){
$date = new DateTime('now');
$date->add(new DateInterval('P10D'));
header('Expires: '.$date->format(DateTime::RFC2822));
OC_Response::setExpiresHeader('P10D');
OC_Response::enableCaching();
OC_Response::redirect(OC_Helper::imagePath('contacts', 'person.png'));
}

View File

@ -42,6 +42,18 @@ class OC_Response {
header('Location: '.$location);
}
static public function setExpiresHeader($expires) {
if (is_string($expires) && $expires[0] == 'P') {
$interval = $expires;
$expires = new DateTime('now');
$expires->add(new DateInterval(expires));
}
if ($expires instanceof DateTime) {
$expires = $expires->format(DateTime::RFC2822);
}
header('Expires: '.expires);
}
static public function setETagHeader($etag) {
if (empty($etag)) {
return;