@@ -371,22 +371,28 @@ protected function httpHead() {
371371
372372 $ node = $ this ->tree ->getNodeForPath ($ this ->getRequestUri ());
373373
374- if (!($ node instanceof Sabre_DAV_IFile)) throw new Sabre_DAV_Exception_NotImplemented ('HEAD is only implemented on File objects ' );
374+ /* This information is only collection for File objects.
375+ * Ideally we want to throw 405 Method Not Allowed for every
376+ * non-file, but MS Office does not like this
377+ */
378+ if ($ node instanceof Sabre_DAV_IFile) {
379+ if ($ size = $ node ->getSize ())
380+ $ this ->httpResponse ->setHeader ('Content-Length ' ,$ size );
375381
376- if ($ size = $ node ->getSize ())
377- $ this ->httpResponse ->setHeader ('Content-Length ' ,$ size );
382+ if ($ etag = $ node ->getETag ()) {
378383
379- if ( $ etag = $ node -> getETag ()) {
384+ $ this -> httpResponse -> setHeader ( ' ETag ' , $ etag );
380385
381- $ this -> httpResponse -> setHeader ( ' ETag ' , $ etag );
386+ }
382387
383- }
388+ if (!$ contentType = $ node ->getContentType ())
389+ $ contentType = 'application/octet-stream ' ;
384390
385- if (! $ contentType = $ node -> getContentType ())
386- $ contentType = ' application/octet-stream ' ;
387-
388- $ this -> httpResponse -> setHeader ( ' Content-Type ' , $ contentType );
389- $ this -> httpResponse -> setHeader ( ' Last-Modified ' , date (DateTime:: RFC1123 , $ node -> getLastModified ()));
391+ $ this -> httpResponse -> setHeader ( ' Content-Type ' , $ contentType );
392+ if ( $ lastMod = $ node -> getLastModified ()) {
393+ $ this -> httpResponse -> setHeader ( ' Last-Modified ' , date (DateTime:: RFC1123 , $ node -> getLastModified ()));
394+ }
395+ }
390396 $ this ->httpResponse ->sendStatus (200 );
391397
392398 }
0 commit comments