File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,10 @@ protected function httpGet() {
370370 protected function httpHead () {
371371
372372 $ node = $ this ->tree ->getNodeForPath ($ this ->getRequestUri ());
373- if ($ node instanceof Sabre_DAV_IFile && $ size = $ node ->getSize ())
373+
374+ if (!($ node instanceof Sabre_DAV_IFile)) throw new Sabre_DAV_Exception_NotImplemented ('HEAD is only implemented on File objects ' );
375+
376+ if ($ size = $ node ->getSize ())
374377 $ this ->httpResponse ->setHeader ('Content-Length ' ,$ size );
375378
376379 if ($ etag = $ node ->getETag ()) {
Original file line number Diff line number Diff line change @@ -298,6 +298,44 @@ function testNonExistantMethod() {
298298
299299 }
300300
301+ function testGETOnCollection () {
302+
303+ $ serverVars = array (
304+ 'REQUEST_URI ' => '/ ' ,
305+ 'REQUEST_METHOD ' => 'GET ' ,
306+ );
307+
308+ $ request = new Sabre_HTTP_Request ($ serverVars );
309+ $ this ->server ->httpRequest = ($ request );
310+ $ this ->server ->exec ();
311+
312+ $ this ->assertEquals (array (
313+ 'Content-Type ' => 'application/xml; charset=utf-8 ' ,
314+ ),$ this ->response ->headers );
315+
316+ $ this ->assertEquals ('HTTP/1.1 501 Not Implemented ' ,$ this ->response ->status );
317+
318+ }
319+
320+ function testHEADOnCollection () {
321+
322+ $ serverVars = array (
323+ 'REQUEST_URI ' => '/ ' ,
324+ 'REQUEST_METHOD ' => 'HEAD ' ,
325+ );
326+
327+ $ request = new Sabre_HTTP_Request ($ serverVars );
328+ $ this ->server ->httpRequest = ($ request );
329+ $ this ->server ->exec ();
330+
331+ $ this ->assertEquals (array (
332+ 'Content-Type ' => 'application/xml; charset=utf-8 ' ,
333+ ),$ this ->response ->headers );
334+
335+ $ this ->assertEquals ('HTTP/1.1 501 Not Implemented ' ,$ this ->response ->status );
336+
337+ }
338+
301339 function testBaseUri () {
302340
303341 $ serverVars = array (
You can’t perform that action at this time.
0 commit comments