diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index 9c68e0789b4f9cae69544820ce3b1c70a6af5054..0cdd0a86c7460cf539833233c64ae5c627ec709a 100644 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -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')); } diff --git a/lib/response.php b/lib/response.php index 5f095a0affdddf1f456fd88a112a106045f72780..7733168b5b98b81b2de7fad30190e2e6acc2b959 100644 --- a/lib/response.php +++ b/lib/response.php @@ -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;