From dfefa2be5572435302542fcf588e75c4e249a43c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 27 May 2013 08:04:06 +0200 Subject: [PATCH] Only return collection on GET. Opens up for using HEAD to get status. --- lib/controller/addressbookcontroller.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/controller/addressbookcontroller.php b/lib/controller/addressbookcontroller.php index b2c3bf6e..cec7b9ad 100644 --- a/lib/controller/addressbookcontroller.php +++ b/lib/controller/addressbookcontroller.php @@ -60,15 +60,17 @@ class AddressBookController extends BaseController { $response->setETag(md5($lastModified)); } - $contacts = array(); - foreach($addressBook->getChildren() as $i => $contact) { - $result = JSONSerializer::serializeContact($contact); - //\OCP\Util::writeLog('contacts', __METHOD__.' contact: '.print_r($result, true), \OCP\Util::DEBUG); - if($result !== null) { - $contacts[] = $result; + if($this->request->method === 'GET') { + $contacts = array(); + foreach($addressBook->getChildren() as $i => $contact) { + $result = JSONSerializer::serializeContact($contact); + //\OCP\Util::writeLog('contacts', __METHOD__.' contact: '.print_r($result, true), \OCP\Util::DEBUG); + if($result !== null) { + $contacts[] = $result; + } } + $response->setParams(array('contacts' => $contacts)); } - $response->setParams(array('contacts' => $contacts)); return $response; }