Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0RC8

Request #11902 Implement HEAD in Filesystem and Reuse in GET
Submitted: 2007-08-24 14:18 UTC
From: kills Assigned: hholzgra
Status: Closed Package: HTTP_WebDAV_Server (version 1.0.0RC4)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 40 + 9 = ?

 
 [2007-08-24 14:18 UTC] kills (Markus Staab)
Description: ------------ would be nice to have a HEAD Method in Filesystem and reuse it in the GET Method. So, the filesystem gets support for HEAD and does also do the GET stuff very well.. Test script: --------------- replace current (1.0.0RC4) implementation with the following function _folderSize($fspath) { $size = 0; $handle = opendir($fspath); if($handle) { while($filename = readdir($handle)) { if($filename == '.' || $filename == '..') continue; $subdir = $fspath .'/'. $filename; if(is_dir($subdir)) $size += $this->_folderSize($subdir); else $size += filesize($subdir); } closedir($handle); } return $size; } /** * HEAD method handler * * @param array parameter passing array * @return bool true on success */ function HEAD(& $options) { // get absolute fs path to requested resource $fspath = $this->base . $options["path"]; // sanity check if (!file_exists($fspath)) return false; // detect resource type $options['mimetype'] = $this->_mimetype($fspath); // detect modification time // see rfc2518, section 13.7 // some clients seem to treat this as a reverse rule // requiering a Last-Modified header if the getlastmodified header was set $options['mtime'] = filemtime($fspath); $options['size'] = 0; if (is_dir($fspath)) { $options['size'] = $this->_folderSize($fspath); } else { // detect resource size $options['size'] = filesize($fspath); } return true; } /** * GET method handler * * @param array parameter passing array * @return bool true on success */ function GET(& $options) { // get absolute fs path to requested resource $fspath = $this->base . $options["path"]; // sanity check if (!file_exists($fspath)) return false; // is this a collection? if (is_dir($fspath)) return $this->GetDir($fspath, $options); // get metadata if(!$this->HEAD($options)) return false; // no need to check result here, it is handled by the base class $options['stream'] = fopen($fspath, "r"); return true; }

Comments

 [2007-11-14 13:46 UTC] hholzgra (Hartmut Holzgraefe)
Fixed in CVS Implemented HEAD(), didn't add the directory handling for HEAD though, WebDAV clients will never do a GET or HEAD on a directory anyway, this was only meant for regular browsers or other HTTP clients hitting the webdav resource by accident