summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-03-27 13:10:27 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-27 13:10:27 +0100
commit7ad4dfa2017d5a1d956cae132a495811588e1352 (patch)
tree4145507d0f235682d3835978983f19ff0d570f55 /lib
parent5aa81833f9bd70929985425c2d78628f76fe728e (diff)
parent70acd58336925ade7ff42c8ea4759a67c09b9212 (diff)
downloadnextcloud-server-7ad4dfa2017d5a1d956cae132a495811588e1352.tar.gz
nextcloud-server-7ad4dfa2017d5a1d956cae132a495811588e1352.zip
Merge pull request #15227 from owncloud/ocetag-header
Copy Etag header to OC-Etag for sabre calls
Diffstat (limited to 'lib')
-rw-r--r--lib/private/connector/sabre/copyetagheaderplugin.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/private/connector/sabre/copyetagheaderplugin.php b/lib/private/connector/sabre/copyetagheaderplugin.php
new file mode 100644
index 00000000000..9f5d74654cc
--- /dev/null
+++ b/lib/private/connector/sabre/copyetagheaderplugin.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @author Vincent Petry
+ * @copyright 2015 Vincent Petry <pvince81@owncloud.com>
+ *
+ * @license AGPL3
+ */
+
+namespace OC\Connector\Sabre;
+
+use \Sabre\HTTP\RequestInterface;
+use \Sabre\HTTP\ResponseInterface;
+
+/**
+ * Copies the "Etag" header to "OC-Etag" after any request.
+ * This is a workaround for setups that automatically strip
+ * or mangle Etag headers.
+ */
+class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin {
+ /**
+ * This initializes the plugin.
+ *
+ * @param \Sabre\DAV\Server $server Sabre server
+ *
+ * @return void
+ */
+ public function initialize(\Sabre\DAV\Server $server) {
+ $server->on('afterMethod', array($this, 'afterMethod'));
+ }
+
+ /**
+ * After method, copy the "Etag" header to "OC-Etag" header.
+ *
+ * @param RequestInterface $request request
+ * @param ResponseInterface $response response
+ */
+ public function afterMethod(RequestInterface $request, ResponseInterface $response) {
+ $eTag = $response->getHeader('Etag');
+ if (!empty($eTag)) {
+ $response->setHeader('OC-ETag', $eTag);
+ }
+ }
+}