Add HEAD request management for files ajax/download.php

This commit is contained in:
Brice Maron 2012-05-24 22:48:10 +00:00
parent d8ca4f78cf
commit 2774ff1ad8
2 changed files with 8 additions and 2 deletions

View File

@ -33,5 +33,5 @@ OCP\User::checkLoggedIn();
$files = $_GET["files"]; $files = $_GET["files"];
$dir = $_GET["dir"]; $dir = $_GET["dir"];
OC_Files::get($dir,$files); OC_Files::get($dir, $files, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
?> ?>

View File

@ -52,8 +52,9 @@ class OC_Files {
* *
* @param dir $dir * @param dir $dir
* @param file $file ; seperated list of files to download * @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,';')){ if(strpos($files,';')){
$files=explode(';',$files); $files=explode(';',$files);
} }
@ -118,6 +119,11 @@ class OC_Files {
header("HTTP/1.0 403 Forbidden"); header("HTTP/1.0 403 Forbidden");
die('403 Forbidden'); die('403 Forbidden');
} }
if($only_header){
if(!$zip)
header("Content-Length: ".OC_Filesystem::filesize($filename));
return ;
}
if($zip){ if($zip){
$handle=fopen($filename,'r'); $handle=fopen($filename,'r');
if ($handle) { if ($handle) {