[Pkg-owncloud-commits] [php-sabredav] 127/163: Returning etags on failed precondition checks.

David Prévot taffit at moszumanska.debian.org
Tue May 20 18:55:01 UTC 2014


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

taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.

commit 0b0bf3c499017a9f52eac769c5bbf9085627471c
Author: Evert Pot <me at evertpot.com>
Date:   Thu May 8 00:18:23 2014 -0400

    Returning etags on failed precondition checks.
    
    Closes #175.
---
 lib/DAV/Server.php                         | 2 ++
 tests/Sabre/DAV/ServerPreconditionTest.php | 9 +++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index ff89da9..ea69a05 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -1310,6 +1310,7 @@ class Server extends EventEmitter {
 
                 }
                 if (!$haveMatch) {
+                    if ($etag) $response->setHeader('ETag', $etag);
                      throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.','If-Match');
                 }
             }
@@ -1350,6 +1351,7 @@ class Server extends EventEmitter {
                 }
 
                 if ($haveMatch) {
+                    if ($etag) $response->setHeader('ETag', $etag);
                     if ($request->getMethod()==='GET') {
                         $response->setStatus(304);
                         return false;
diff --git a/tests/Sabre/DAV/ServerPreconditionTest.php b/tests/Sabre/DAV/ServerPreconditionTest.php
index a66e823..37a47f7 100644
--- a/tests/Sabre/DAV/ServerPreconditionTest.php
+++ b/tests/Sabre/DAV/ServerPreconditionTest.php
@@ -204,15 +204,12 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase {
 
         $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
         $server = new Server($root);
-        $httpRequest = HTTP\Sapi::createFromServerArray(array(
-            'REQUEST_METHOD' => 'GET',
-            'HTTP_IF_NONE_MATCH' => '"abc123"',
-            'REQUEST_URI'   => '/foo'
-        ));
+        $httpRequest = new HTTP\Request('GET', '/foo', ['If-None-Match' => '"abc123"']);
         $server->httpResponse = new HTTP\ResponseMock();
 
         $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse));
-        $this->assertEquals(304, $server->httpResponse->status);
+        $this->assertEquals(304, $server->httpResponse->getStatus());
+        $this->assertEquals(['ETag' => '"abc123"'], $server->httpResponse->getHeaders());
 
     }
 

-- 
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