301 on PROPFIND method with webdavclient

603 views
Skip to first unread message

JC

unread,
Jan 10, 2012, 4:50:59 AM1/10/12
to SabreDAV Discussion
Hi everyone,

I got an strange error with propfind method of Sabre_DAV_Client class.

This is my code :

$settings = array(
'baseUri' => 'http://mywebdav.com/folder',
'userName' => 'login',
'password' => 'password'
);

$client = new Sabre_DAV_Client($settings);

print_r($client->propfind($settings['baseUri'], array(
'{DAV:}displayname',
'{DAV:}getcontentlength'
)));

This trows me an error in apache log :

[error] [client ::1] PHP Fatal error: Uncaught exception
'InvalidArgumentException' with message 'The passed data is not valid
XML' in /var/www/webdav/classes/Sabre/DAV/Client.php:398\nStack trace:
\n#0 /var/www/webdav/classes/Sabre/DAV/Client.php(112):
Sabre_DAV_Client->parseMultiStatus('<!DOCTYPE HTML ...')\n#1 /var/www/
webdav/ajax/fileManager/getFiles.php(22): Sabre_DAV_Client-
>propFind('https://mywebd...', Array)\n#2 {main}\n thrown in /var/www/
webdav/classes/Sabre/DAV/Client.php on line 398, referer: http://localhost/webdav

Ok this is a 301 Moved Permanently. But when I try a GET request on a
file inside this directory, request is successull. No 301.

What is wrong ? Apache configuration ?

Thank's in advance,

JC

Evert Pot

unread,
Jan 10, 2012, 5:49:18 AM1/10/12
to sabredav...@googlegroups.com
Hi JC,

The client doesn't automatically follow redirects. I just pushed a fix to github to make this work though.

But even without that, you can fix it by just adding a / to your url.

http://mywebdav.com/folder/

Contrary to popular believe, the following urls are actually distinct:

http://example.org/folder
http://example.org/folder/

Most applications choose to handle them the same way, but this is really not a great idea. Apache will always do the redirect, even for non-webdav access.

Evert

JC

unread,
Jan 10, 2012, 5:56:57 AM1/10/12
to SabreDAV Discussion
Hi Evert,

First thank's for your answer.

I add a / to my url. Unfortunately, this doesn't work... I got an 405
status code... Method Not Allowed. Does it mean that my server is not
webdav ? This is strange if a GET request works...

Also, following the documentation, I try the $client->options();
method. This returns me nothing.

Thanks for your help,

JC
> http://example.org/folderhttp://example.org/folder/

JC

unread,
Jan 11, 2012, 3:30:42 AM1/11/12
to SabreDAV Discussion
OK, find the solution...

In fact I get a 405 status code because the webdav server doesn't
allow PROPFIND with depth greater than 1. The default is 0 which means
infinity.

Regards,

JC

Evert Pot

unread,
Jan 11, 2012, 5:03:19 AM1/11/12
to sabredav...@googlegroups.com
On Jan 11, 2012, at 9:30 AM, JC wrote:

> OK, find the solution...
>
> In fact I get a 405 status code because the webdav server doesn't
> allow PROPFIND with depth greater than 1. The default is 0 which means
> infinity.

0 != Infinity.

0 Means only the top-level item. So if this indeed works, your server is broken.

Evert

Reply all
Reply to author
Forward
0 new messages