Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't works with Synology CardDAV Server #24

Open
knuz92 opened this issue Dec 6, 2014 · 2 comments
Open

Don't works with Synology CardDAV Server #24

knuz92 opened this issue Dec 6, 2014 · 2 comments

Comments

@knuz92
Copy link

knuz92 commented Dec 6, 2014

Here my code:

$carddav = new carddav_backend('http://ip:8008/addressbooks/users/contacts/addressbook/');
$carddav->set_auth('contacts', 'mypw');
echo $carddav->get();

And the error:

Fatal error: Uncaught exception 'Exception' with message '1Woops, something's gone wrong! 
The CardDAV server returned the http status code 401.' in /volume1/web/carddav.php:285 
Stack trace: #0 /volume1/web/contacts.php(9): carddav_backend->get(false) #1 {main} thrown in /volume1/web/carddav.php on line 285
@mvwd
Copy link

mvwd commented Jun 29, 2017

Method get() will only list all vCards + Properties (with method PROPFIND). As per RFC PROPFIND has to have a header-element "Depth" with value "0", "1" or "infinity" (sending NO header "Depth" the server has to assume its "infinity").

Server must answer Depth=0 or 1, but only SHOULD answer to "infinity".
And guess what: Syno-CardDav does not answer/allow PROPFIND "infinity".

Solving the problem is simply adding a header-element "Depth: 1"; shouldn't affect other servers.

Just replace Line 621:
curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-type: '.$content_type));
with:
curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-type: '.$content_type, 'Depth: 1'));

Thx for the project!
And YES: i saw this issue is from 2014 ;-)

@kmpoppe
Copy link

kmpoppe commented Mar 14, 2021

So ...

after another almost 4 years I thought I'd spare people the hassle getting this module to work with a Synology ;-)

@mvwd 's addition worked like a charm, YET - when using get() only, the content-type is still NULL so the Depth: 1doesn't even get sent.

Solution: In Line 268 (First line in function get) replace
$result = $this->query($this->url, 'PROPFIND');
with
$result = $this->query($this->url, 'PROPFIND', null, 'text/xml');

This might also solve the problem described in #27.

Additionally, for my Synology DS218+, I needed to specify the addressbook's-URL in full, e.g.:
$carddav = new carddav_backend('https://<URL>:<PORT>/addressbooks/users/<USERNAME>/addressbook');

Thanks for the great project @christian-putzke and @mvwd for the nudge in the right direction!

Kai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants