From 594dcf13f2d311ba2161e33effe6e297939e3595 Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Mon, 13 Feb 2012 22:47:31 +0100
Subject: [PATCH] Contacts+OC_Respone: Move enableCaching out of setEtagHeader
 and setLastModifiedHeader

---
 apps/contacts/photo.php     | 1 +
 apps/contacts/thumbnail.php | 1 +
 lib/response.php            | 3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 314bce7cec..8dfbcb6fb1 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -21,6 +21,7 @@ $image = new OC_Image();
 if( is_null($contact)) {
 	OC_Log::write('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR);
 } else {
+	OC_Response::enableCaching();
 	OC_Contacts_App::setLastModifiedHeader($contact);
 
 	// Photo :-)
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index c020c29ac8..39da6bc2bf 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -48,6 +48,7 @@ if(is_null($contact)){
 	getStandardImage();
 	exit();
 }
+OC_Response::enableCaching();
 OC_Contacts_App::setLastModifiedHeader($contact);
 
 $thumbnail_size = 23;
diff --git a/lib/response.php b/lib/response.php
index b5fca1cb22..a768366b02 100644
--- a/lib/response.php
+++ b/lib/response.php
@@ -63,6 +63,7 @@ class OC_Response {
 			$expires->add(new DateInterval($interval));
 		}
 		if ($expires instanceof DateTime) {
+			$expires->setTimezone(new DateTimeZone('GMT'));
 			$expires = $expires->format(DateTime::RFC2822);
 		}
 		header('Expires: '.$expires);
@@ -72,7 +73,6 @@ class OC_Response {
 		if (empty($etag)) {
 			return;
 		}
-		self::enableCaching();
 		if (isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
 		    trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
 			self::setStatus(self::STATUS_NOT_MODIFIED);
@@ -88,7 +88,6 @@ class OC_Response {
 		if ($lastModified instanceof DateTime) {
 			$lastModified = $lastModified->format(DateTime::RFC2822);
 		}
-		self::enableCaching();
 		if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
 		    trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
 			self::setStatus(self::STATUS_NOT_MODIFIED);
-- 
GitLab