list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
'method' => 'HEAD',
'url' => $this->storageUrl( $auth, $srcCont, $srcRel ),
- 'headers' => $this->authTokenHeaders( $auth )
+ 'headers' => $this->authTokenHeaders( $auth ) + $this->headersFromParams( $params )
) );
if ( $rcode === 200 || $rcode === 204 ) {
// Update the object if it is missing some headers
$auth = $this->getAuthentication();
if ( !$auth ) {
$objHdrs['x-object-meta-sha1base36'] = false;
- return false; // failed
+ return $objHdrs; // failed
}
$status = Status::newGood();
'headers' => $this->authTokenHeaders( $auth ) + $objHdrs
) );
if ( $rcode >= 200 && $rcode <= 299 ) {
- return true; // success
+ return $objHdrs; // success
}
}
}
trigger_error( "Unable to set SHA-1 metadata for $path", E_USER_WARNING );
$objHdrs['x-object-meta-sha1base36'] = false;
- return false; // failed
+ return $objHdrs; // failed
}
protected function doGetFileContentsMulti( array $params ) {
fclose( $op['stream'] ); // close open handle
if ( $rcode >= 200 && $rcode <= 299
// double check that the disk is not full/broken
- && $tmpFile->getSize() == $rhdrs['content-length']
+ && $tmpFiles[$path]->getSize() == $rhdrs['content-length']
) {
// good
} elseif ( $rcode === 404 ) {
if ( $this->swiftTempUrlKey != '' ) {
$url = $this->storageUrl( $auth, $srcCont, $srcRel );
+ // Swift wants the signature based on the unencoded object name
+ $contPath = parse_url( $this->storageUrl( $auth, $srcCont ), PHP_URL_PATH );
$signature = hash_hmac( 'sha1',
- "GET\n{$expires}\n" . parse_url( $url, PHP_URL_PATH ),
+ "GET\n{$expires}\n{$contPath}/{$srcRel}",
$this->swiftTempUrlKey
);
return "{$url}?temp_url_sig={$signature}&temp_url_expires={$expires}";
protected function headersFromParams( array $params ) {
$hdrs = array();
if ( !empty( $params['latest'] ) ) {
- $hdrs[] = 'X-Newest: true';
+ $hdrs['x-newest'] = 'true';
}
return $hdrs;
* Log an unexpected exception for this backend.
* This also sets the Status object to have a fatal error.
*
- * @param Status $code null
+ * @param Status|null $status
* @param string $func
* @param array $params
* @param string $err Error string
- * @param integer $status HTTP status
+ * @param integer $code HTTP status
* @param string $desc HTTP status description
*/
public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '' ) {