@@ -36,56 +36,56 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin { |
| 38 | 38 | |
| 39 | - /** @var \Sabre\DAV\Server */ |
|
| 40 | - private $server; |
|
| 41 | - /** |
|
| 42 | - * This initializes the plugin. |
|
| 43 | - * |
|
| 44 | - * @param \Sabre\DAV\Server $server Sabre server |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - public function initialize(\Sabre\DAV\Server $server) { |
|
| 49 | - $this->server = $server; |
|
| 39 | + /** @var \Sabre\DAV\Server */ |
|
| 40 | + private $server; |
|
| 41 | + /** |
|
| 42 | + * This initializes the plugin. |
|
| 43 | + * |
|
| 44 | + * @param \Sabre\DAV\Server $server Sabre server |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + public function initialize(\Sabre\DAV\Server $server) { |
|
| 49 | + $this->server = $server; |
|
| 50 | 50 | |
| 51 | - $server->on('afterMethod:*', [$this, 'afterMethod']); |
|
| 52 | - $server->on('afterMove', [$this, 'afterMove']); |
|
| 53 | - } |
|
| 51 | + $server->on('afterMethod:*', [$this, 'afterMethod']); |
|
| 52 | + $server->on('afterMove', [$this, 'afterMove']); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * After method, copy the "Etag" header to "OC-Etag" header. |
|
| 57 | - * |
|
| 58 | - * @param RequestInterface $request request |
|
| 59 | - * @param ResponseInterface $response response |
|
| 60 | - */ |
|
| 61 | - public function afterMethod(RequestInterface $request, ResponseInterface $response) { |
|
| 62 | - $eTag = $response->getHeader('Etag'); |
|
| 63 | - if (!empty($eTag)) { |
|
| 64 | - $response->setHeader('OC-ETag', $eTag); |
|
| 65 | - } |
|
| 66 | - } |
|
| 55 | + /** |
|
| 56 | + * After method, copy the "Etag" header to "OC-Etag" header. |
|
| 57 | + * |
|
| 58 | + * @param RequestInterface $request request |
|
| 59 | + * @param ResponseInterface $response response |
|
| 60 | + */ |
|
| 61 | + public function afterMethod(RequestInterface $request, ResponseInterface $response) { |
|
| 62 | + $eTag = $response->getHeader('Etag'); |
|
| 63 | + if (!empty($eTag)) { |
|
| 64 | + $response->setHeader('OC-ETag', $eTag); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Called after a node is moved. |
|
| 70 | - * |
|
| 71 | - * This allows the backend to move all the associated properties. |
|
| 72 | - * |
|
| 73 | - * @param string $source |
|
| 74 | - * @param string $destination |
|
| 75 | - * @return void |
|
| 76 | - */ |
|
| 77 | - public function afterMove($source, $destination) { |
|
| 78 | - try { |
|
| 79 | - $node = $this->server->tree->getNodeForPath($destination); |
|
| 80 | - } catch (NotFound $e) { |
|
| 81 | - // Don't care |
|
| 82 | - return; |
|
| 83 | - } |
|
| 68 | + /** |
|
| 69 | + * Called after a node is moved. |
|
| 70 | + * |
|
| 71 | + * This allows the backend to move all the associated properties. |
|
| 72 | + * |
|
| 73 | + * @param string $source |
|
| 74 | + * @param string $destination |
|
| 75 | + * @return void |
|
| 76 | + */ |
|
| 77 | + public function afterMove($source, $destination) { |
|
| 78 | + try { |
|
| 79 | + $node = $this->server->tree->getNodeForPath($destination); |
|
| 80 | + } catch (NotFound $e) { |
|
| 81 | + // Don't care |
|
| 82 | + return; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if ($node instanceof File) { |
|
| 86 | - $eTag = $node->getETag(); |
|
| 87 | - $this->server->httpResponse->setHeader('OC-ETag', $eTag); |
|
| 88 | - $this->server->httpResponse->setHeader('ETag', $eTag); |
|
| 89 | - } |
|
| 90 | - } |
|
| 85 | + if ($node instanceof File) { |
|
| 86 | + $eTag = $node->getETag(); |
|
| 87 | + $this->server->httpResponse->setHeader('OC-ETag', $eTag); |
|
| 88 | + $this->server->httpResponse->setHeader('ETag', $eTag); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | } |