aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/Client.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
committerMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
commitbde429cff649237984903a252ba1a718e6d74f53 (patch)
treeb2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/sabre/dav/lib/DAV/Client.php
parentcc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff)
parent4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff)
downloadvolse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.gz
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.bz2
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.zip
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Client.php')
-rw-r--r--vendor/sabre/dav/lib/DAV/Client.php136
1 files changed, 66 insertions, 70 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php
index 175ad1bc4..cfa24cd29 100644
--- a/vendor/sabre/dav/lib/DAV/Client.php
+++ b/vendor/sabre/dav/lib/DAV/Client.php
@@ -1,12 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
use Sabre\HTTP;
use Sabre\Uri;
/**
- * SabreDAV DAV client
+ * SabreDAV DAV client.
*
* This client wraps around Curl to provide a convenient API to a WebDAV
* server.
@@ -17,8 +19,8 @@ use Sabre\Uri;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Client extends HTTP\Client {
-
+class Client extends HTTP\Client
+{
/**
* The xml service.
*
@@ -29,18 +31,19 @@ class Client extends HTTP\Client {
public $xml;
/**
- * The elementMap
+ * The elementMap.
*
* This property is linked via reference to $this->xml->elementMap.
* It's deprecated as of version 3.0.0, and should no longer be used.
*
* @deprecated
+ *
* @var array
*/
public $propertyMap = [];
/**
- * Base URI
+ * Base URI.
*
* This URI will be used to resolve relative urls.
*
@@ -49,17 +52,17 @@ class Client extends HTTP\Client {
protected $baseUri;
/**
- * Basic authentication
+ * Basic authentication.
*/
const AUTH_BASIC = 1;
/**
- * Digest authentication
+ * Digest authentication.
*/
const AUTH_DIGEST = 2;
/**
- * NTLM authentication
+ * NTLM authentication.
*/
const AUTH_NTLM = 4;
@@ -69,12 +72,12 @@ class Client extends HTTP\Client {
const ENCODING_IDENTITY = 1;
/**
- * Deflate encoding
+ * Deflate encoding.
*/
const ENCODING_DEFLATE = 2;
/**
- * Gzip encoding
+ * Gzip encoding.
*/
const ENCODING_GZIP = 4;
@@ -84,14 +87,14 @@ class Client extends HTTP\Client {
const ENCODING_ALL = 7;
/**
- * Content-encoding
+ * Content-encoding.
*
* @var int
*/
protected $encoding = self::ENCODING_IDENTITY;
/**
- * Constructor
+ * Constructor.
*
* Settings are provided through the 'settings' argument. The following
* settings are supported:
@@ -112,8 +115,8 @@ class Client extends HTTP\Client {
*
* @param array $settings
*/
- function __construct(array $settings) {
-
+ public function __construct(array $settings)
+ {
if (!isset($settings['baseUri'])) {
throw new \InvalidArgumentException('A baseUri must be provided');
}
@@ -146,8 +149,7 @@ class Client extends HTTP\Client {
}
$this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType);
- $this->addCurlSetting(CURLOPT_USERPWD, $userName . ':' . $password);
-
+ $this->addCurlSetting(CURLOPT_USERPWD, $userName.':'.$password);
}
if (isset($settings['encoding'])) {
@@ -166,16 +168,15 @@ class Client extends HTTP\Client {
$this->addCurlSetting(CURLOPT_ENCODING, implode(',', $encodings));
}
- $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/' . Version::VERSION . ' (http://sabre.io/)');
+ $this->addCurlSetting(CURLOPT_USERAGENT, 'sabre-dav/'.Version::VERSION.' (http://sabre.io/)');
$this->xml = new Xml\Service();
// BC
- $this->propertyMap = & $this->xml->elementMap;
-
+ $this->propertyMap = &$this->xml->elementMap;
}
/**
- * Does a PROPFIND request
+ * Does a PROPFIND request.
*
* The list of requested properties must be specified as an array, in clark
* notation.
@@ -191,28 +192,28 @@ class Client extends HTTP\Client {
* made to the server to also return all child resources.
*
* @param string $url
- * @param array $properties
- * @param int $depth
+ * @param array $properties
+ * @param int $depth
+ *
* @return array
*/
- function propFind($url, array $properties, $depth = 0) {
-
+ public function propFind($url, array $properties, $depth = 0)
+ {
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$root = $dom->createElementNS('DAV:', 'd:propfind');
$prop = $dom->createElement('d:prop');
foreach ($properties as $property) {
-
list(
$namespace,
$elementName
) = \Sabre\Xml\Service::parseClarkNotation($property);
- if ($namespace === 'DAV:') {
- $element = $dom->createElement('d:' . $elementName);
+ if ('DAV:' === $namespace) {
+ $element = $dom->createElement('d:'.$elementName);
} else {
- $element = $dom->createElementNS($namespace, 'x:' . $elementName);
+ $element = $dom->createElementNS($namespace, 'x:'.$elementName);
}
$prop->appendChild($element);
@@ -224,49 +225,48 @@ class Client extends HTTP\Client {
$url = $this->getAbsoluteUrl($url);
$request = new HTTP\Request('PROPFIND', $url, [
- 'Depth' => $depth,
- 'Content-Type' => 'application/xml'
+ 'Depth' => $depth,
+ 'Content-Type' => 'application/xml',
], $body);
$response = $this->send($request);
- if ((int)$response->getStatus() >= 400) {
+ if ((int) $response->getStatus() >= 400) {
throw new HTTP\ClientHttpException($response);
}
$result = $this->parseMultiStatus($response->getBodyAsString());
// If depth was 0, we only return the top item
- if ($depth === 0) {
+ if (0 === $depth) {
reset($result);
$result = current($result);
+
return isset($result[200]) ? $result[200] : [];
}
$newResult = [];
foreach ($result as $href => $statusList) {
-
$newResult[$href] = isset($statusList[200]) ? $statusList[200] : [];
-
}
return $newResult;
-
}
/**
- * Updates a list of properties on the server
+ * Updates a list of properties on the server.
*
* The list of properties must have clark-notation properties for the keys,
* and the actual (string) value for the value. If the value is null, an
* attempt is made to delete the property.
*
* @param string $url
- * @param array $properties
+ * @param array $properties
+ *
* @return bool
*/
- function propPatch($url, array $properties) {
-
+ public function propPatch($url, array $properties)
+ {
$propPatch = new Xml\Request\PropPatch();
$propPatch->properties = $properties;
$xml = $this->xml->write(
@@ -284,7 +284,7 @@ class Client extends HTTP\Client {
throw new HTTP\ClientHttpException($response);
}
- if ($response->getStatus() === 207) {
+ if (207 === $response->getStatus()) {
// If it's a 207, the request could still have failed, but the
// information is hidden in the response body.
$result = $this->parseMultiStatus($response->getBodyAsString());
@@ -292,26 +292,23 @@ class Client extends HTTP\Client {
$errorProperties = [];
foreach ($result as $href => $statusList) {
foreach ($statusList as $status => $properties) {
-
if ($status >= 400) {
foreach ($properties as $propName => $propValue) {
- $errorProperties[] = $propName . ' (' . $status . ')';
+ $errorProperties[] = $propName.' ('.$status.')';
}
}
-
}
}
if ($errorProperties) {
-
- throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: ' . implode(', ', $errorProperties));
+ throw new HTTP\ClientException('PROPPATCH failed. The following properties errored: '.implode(', ', $errorProperties));
}
}
- return true;
+ return true;
}
/**
- * Performs an HTTP options request
+ * Performs an HTTP options request.
*
* This method returns all the features from the 'DAV:' header as an array.
* If there was no DAV header, or no contents this method will return an
@@ -319,8 +316,8 @@ class Client extends HTTP\Client {
*
* @return array
*/
- function options() {
-
+ public function options()
+ {
$request = new HTTP\Request('OPTIONS', $this->getAbsoluteUrl(''));
$response = $this->send($request);
@@ -333,8 +330,8 @@ class Client extends HTTP\Client {
foreach ($features as &$v) {
$v = trim($v);
}
- return $features;
+ return $features;
}
/**
@@ -359,24 +356,26 @@ class Client extends HTTP\Client {
* Note that it is no longer recommended to use this method, use the send()
* method instead.
*
- * @param string $method
- * @param string $url
+ * @param string $method
+ * @param string $url
* @param string|resource|null $body
- * @param array $headers
- * @throws ClientException, in case a curl error occurred.
+ * @param array $headers
+ *
+ * @throws clientException, in case a curl error occurred
+ *
* @return array
*/
- function request($method, $url = '', $body = null, array $headers = []) {
-
+ public function request($method, $url = '', $body = null, array $headers = [])
+ {
$url = $this->getAbsoluteUrl($url);
$response = $this->send(new HTTP\Request($method, $url, $headers, $body));
+
return [
- 'body' => $response->getBodyAsString(),
- 'statusCode' => (int)$response->getStatus(),
- 'headers' => array_change_key_case($response->getHeaders()),
+ 'body' => $response->getBodyAsString(),
+ 'statusCode' => (int) $response->getStatus(),
+ 'headers' => array_change_key_case($response->getHeaders()),
];
-
}
/**
@@ -384,19 +383,19 @@ class Client extends HTTP\Client {
* urls are expanded based on the base url as given by the server.
*
* @param string $url
+ *
* @return string
*/
- function getAbsoluteUrl($url) {
-
+ public function getAbsoluteUrl($url)
+ {
return Uri\resolve(
$this->baseUri,
$url
);
-
}
/**
- * Parses a WebDAV multistatus response body
+ * Parses a WebDAV multistatus response body.
*
* This method returns an array with the following structure
*
@@ -418,22 +417,19 @@ class Client extends HTTP\Client {
*
*
* @param string $body xml body
+ *
* @return array
*/
- function parseMultiStatus($body) {
-
+ public function parseMultiStatus($body)
+ {
$multistatus = $this->xml->expect('{DAV:}multistatus', $body);
$result = [];
foreach ($multistatus->getResponses() as $response) {
-
$result[$response->getHref()] = $response->getResponseProperties();
-
}
return $result;
-
}
-
}