From 84e389ec68a3b91a940e6a9029484f89b451b0aa Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 22 Jul 2015 14:26:31 -0700 Subject: [PATCH] Fixed headers sent in addMissingMetadata() * This used to relay back *all* of the GET headers, which includes things that are not changeable (Content-Length) or make no sense (x-trans-id). Only send the actual HTTP/metadata headers. Oddly enough sending garbage headers gives a 2XX response, but does not actually change anything in Swift. Bug: T105810 Change-Id: Id4829cf998a6d8763fd26d49cd8d9c16cf5527dd --- includes/filebackend/SwiftFileBackend.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 6a0f2ee3e6..3d089df083 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -716,6 +716,11 @@ class SwiftFileBackend extends FileBackendStore { return $objHdrs; // failed } + // Find prior custom HTTP headers + $postHeaders = $this->getCustomHeaders( $objHdrs ); + // Find prior metadata headers + $postHeaders += $this->getMetadataHeaders( $objHdrs ); + $status = Status::newGood(); /** @noinspection PhpUnusedLocalVariableInspection */ $scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status ); @@ -725,11 +730,13 @@ class SwiftFileBackend extends FileBackendStore { $hash = $tmpFile->getSha1Base36(); if ( $hash !== false ) { $objHdrs['x-object-meta-sha1base36'] = $hash; + // Merge new SHA1 header into the old ones + $postHeaders['x-object-meta-sha1base36'] = $hash; list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $path ); - list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array( + list( $rcode ) = $this->http->run( array( 'method' => 'POST', 'url' => $this->storageUrl( $auth, $srcCont, $srcRel ), - 'headers' => $this->authTokenHeaders( $auth ) + $objHdrs + 'headers' => $this->authTokenHeaders( $auth ) + $postHeaders ) ); if ( $rcode >= 200 && $rcode <= 299 ) { $this->deleteFileCache( $path ); -- 2.20.1