diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-06-01 10:59:04 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-06-01 10:59:04 +0200 |
commit | 1b426eda44f59648d2f1c5b79a06c78ff74c9fce (patch) | |
tree | e23e20a6b04013b8072f52cd3406da1c03a849e7 /apps/dav/lib/Connector | |
parent | cf9660fdf055cbc12d7c06f641843f1c3754f797 (diff) | |
download | nextcloud-server-1b426eda44f59648d2f1c5b79a06c78ff74c9fce.tar.gz nextcloud-server-1b426eda44f59648d2f1c5b79a06c78ff74c9fce.zip |
Make X-HAS-{MD5/SHA256} opt-in
This is not always needed and slow down the upload
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/File.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 37fb109a3bd..ebcfdabc6b3 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -215,15 +215,26 @@ class File extends Node implements IFile { $data = $tmpData; } - $data = HashWrapper::wrap($data, 'md5', function ($hash) { - $this->header('X-Hash-MD5: ' . $hash); - }); - $data = HashWrapper::wrap($data, 'sha1', function ($hash) { - $this->header('X-Hash-SHA1: ' . $hash); - }); - $data = HashWrapper::wrap($data, 'sha256', function ($hash) { - $this->header('X-Hash-SHA256: ' . $hash); - }); + if ($this->request->getHeader('X-HASH') !== '') { + $hash = $this->request->getHeader('X-HASH'); + if ($hash === 'all' || $hash === 'md5') { + $data = HashWrapper::wrap($data, 'md5', function ($hash) { + $this->header('X-Hash-MD5: ' . $hash); + }); + } + + if ($hash === 'all' || $hash === 'sha1') { + $data = HashWrapper::wrap($data, 'sha1', function ($hash) { + $this->header('X-Hash-SHA1: ' . $hash); + }); + } + + if ($hash === 'all' || $hash === 'sha256') { + $data = HashWrapper::wrap($data, 'sha256', function ($hash) { + $this->header('X-Hash-SHA256: ' . $hash); + }); + } + } if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { $isEOF = false; |