From 9c2a6fb551487dad29cd327a5f357f2ac28e8edd Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Thu, 24 May 2012 22:48:10 +0000 Subject: [PATCH] Add HEAD request management for files ajax/download.php --- apps/files/ajax/download.php | 2 +- lib/files.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index fd2d9b891f5..e9373f5f6ac 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -33,5 +33,5 @@ OCP\User::checkLoggedIn(); $files = $_GET["files"]; $dir = $_GET["dir"]; -OC_Files::get($dir,$files); +OC_Files::get($dir, $files, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); ?> diff --git a/lib/files.php b/lib/files.php index b405cf1749f..e0c78d22c24 100644 --- a/lib/files.php +++ b/lib/files.php @@ -52,8 +52,9 @@ class OC_Files { * * @param dir $dir * @param file $file ; seperated list of files to download + * @param boolean $only_header ; boolean to only send header of the request */ - public static function get($dir,$files){ + public static function get($dir,$files, $only_header = false){ if(strpos($files,';')){ $files=explode(';',$files); } @@ -118,6 +119,11 @@ class OC_Files { header("HTTP/1.0 403 Forbidden"); die('403 Forbidden'); } + if($only_header){ + if(!$zip) + header("Content-Length: ".OC_Filesystem::filesize($filename)); + return ; + } if($zip){ $handle=fopen($filename,'r'); if ($handle) { -- 2.39.5