[Pkg-owncloud-commits] [php-sabredav] 04/33: Fixes issue #19.

David Prévot taffit at moszumanska.debian.org
Sat Nov 30 15:43:53 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag version-1.0.10
in repository php-sabredav.

commit ca6a74915f439de7a91f9a76059ef6bf88666463
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Tue Feb 23 08:44:20 2010 +0000

    Fixes issue #19.
---
 lib/Sabre/DAV/Server.php             |  5 ++++-
 tests/Sabre/DAV/ServerSimpleTest.php | 38 ++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/lib/Sabre/DAV/Server.php b/lib/Sabre/DAV/Server.php
index 9a7fb0c..80c7fab 100644
--- a/lib/Sabre/DAV/Server.php
+++ b/lib/Sabre/DAV/Server.php
@@ -370,7 +370,10 @@ class Sabre_DAV_Server {
     protected function httpHead() {
 
         $node = $this->tree->getNodeForPath($this->getRequestUri());
-        if ($node instanceof Sabre_DAV_IFile && $size = $node->getSize())
+
+        if (!($node instanceof Sabre_DAV_IFile)) throw new Sabre_DAV_Exception_NotImplemented('HEAD is only implemented on File objects');
+
+        if ($size = $node->getSize())
             $this->httpResponse->setHeader('Content-Length',$size);
 
         if ($etag = $node->getETag()) {
diff --git a/tests/Sabre/DAV/ServerSimpleTest.php b/tests/Sabre/DAV/ServerSimpleTest.php
index 4207e37..c6b7af6 100644
--- a/tests/Sabre/DAV/ServerSimpleTest.php
+++ b/tests/Sabre/DAV/ServerSimpleTest.php
@@ -274,6 +274,44 @@ class Sabre_DAV_ServerSimpleTest extends Sabre_DAV_AbstractServer{
 
     }
 
+    function testGETOnCollection() {
+
+        $serverVars = array(
+            'REQUEST_URI'    => '/',
+            'REQUEST_METHOD' => 'GET',
+        );
+
+        $request = new Sabre_HTTP_Request($serverVars);
+        $this->server->httpRequest = ($request);
+        $this->server->exec();
+
+        $this->assertEquals(array(
+            'Content-Type' => 'application/xml; charset=utf-8',
+        ),$this->response->headers);
+
+        $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status);
+
+    }
+
+    function testHEADOnCollection() {
+
+        $serverVars = array(
+            'REQUEST_URI'    => '/',
+            'REQUEST_METHOD' => 'HEAD',
+        );
+
+        $request = new Sabre_HTTP_Request($serverVars);
+        $this->server->httpRequest = ($request);
+        $this->server->exec();
+
+        $this->assertEquals(array(
+            'Content-Type' => 'application/xml; charset=utf-8',
+        ),$this->response->headers);
+
+        $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status);
+
+    }
+
     function testBaseUri() {
 
         $serverVars = array(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list