private function get_resources_document($path, $depth)
{
$path = $this->get_encoded_path($path);
$headers = array('Depth' => $depth, 'Authorization' => 'Basic ' . base64_encode($this->username . ':' . $this->password));
$response = SimpleHTTP::send('PROPFIND', $this->host, $this->port, $path, array(), $headers);
if (207 != $response['status_code']) {
throw new Exception("Invalid status code returned: `{$response['status_code']}'");
}
$simplified_source = str_replace('D:', '', str_replace('DAV:', '', $response['body']));
// file_put_contents(dirname(__FILE__).'/../../cache/dav-response.log', $simplified_source);
$document = @DOMDocument::loadXML($simplified_source);
if (!$document->documentElement) {
throw new Exception("Invalid content returned from server at `{$path}'.");
}
return $document;
}