summaryrefslogtreecommitdiffstats
path: root/lib/response.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-02-13 23:35:33 +0100
committerBart Visscher <bartv@thisnet.nl>2012-02-13 23:35:37 +0100
commit29fc82c364e2e90330d9858528e50d785e5e66bd (patch)
treec5b50a3b632ee5186cdaca10113a6438f244bfae /lib/response.php
parent594dcf13f2d311ba2161e33effe6e297939e3595 (diff)
downloadnextcloud-server-29fc82c364e2e90330d9858528e50d785e5e66bd.tar.gz
nextcloud-server-29fc82c364e2e90330d9858528e50d785e5e66bd.zip
Send gallery album thumbnail with OC_Response::sendFile
Diffstat (limited to 'lib/response.php')
-rw-r--r--lib/response.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/response.php b/lib/response.php
index a768366b02c..f47534aeefb 100644
--- a/lib/response.php
+++ b/lib/response.php
@@ -10,6 +10,7 @@ class OC_Response {
const STATUS_FOUND = 304;
const STATUS_NOT_MODIFIED = 304;
const STATUS_TEMPORARY_REDIRECT = 307;
+ const STATUS_NOT_FOUND = 404;
static public function enableCaching($cache_time = null) {
if (is_numeric($cache_time)) {
@@ -47,6 +48,9 @@ class OC_Response {
case self::STATUS_FOUND;
$status = $status . ' Found';
break;
+ case self::STATUS_NOT_FOUND;
+ $status = $status . ' Not Found';
+ break;
}
header($protocol.' '.$status);
}
@@ -85,6 +89,9 @@ class OC_Response {
if (empty($lastModified)) {
return;
}
+ if (is_int($lastModified)) {
+ $lastModified = gmdate(DateTime::RFC2822, $lastModified);
+ }
if ($lastModified instanceof DateTime) {
$lastModified = $lastModified->format(DateTime::RFC2822);
}
@@ -95,4 +102,18 @@ class OC_Response {
}
header('Last-Modified: '.$lastModified);
}
+
+ static public function sendFile($filepath=null) {
+ $fp = fopen($filepath, 'rb');
+ if ($fp) {
+ self::setLastModifiedHeader(filemtime($filepath));
+ self::setETagHeader(md5_file($filepath));
+
+ header('Content-Length: '.filesize($filepath));
+ fpassthru($fp);
+ }
+ else {
+ self::setStatus(self::STATUS_NOT_FOUND);
+ }
+ }
}