Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ObjectStore/v1/Models/MetadataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public function parseMetadata(ResponseInterface $response): array
$metadata = [];

foreach ($response->getHeaders() as $header => $value) {
$position = strpos($header, static::METADATA_PREFIX);
if ($position === 0) {
$metadata[ltrim($header, static::METADATA_PREFIX)] = $response->getHeader($header)[0];
if (0 === strpos($header, static::METADATA_PREFIX)) {
$name = substr($header, strlen(static::METADATA_PREFIX));
$metadata[$name] = $response->getHeader($header)[0];
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/ObjectStore/v1/Fixtures/HEAD_Object.resp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Last-Modified: Thu, 16 Jan 2014 21:12:31 GMT
Etag: 451e372e48e0f6b1114fa0724aa79fa1
X-Timestamp: 1389906751.73463
X-Object-Meta-Book: GoodbyeColumbus
X-Object-Meta-Manufacturer: Acme
Content-Type: application/octet-stream
X-Trans-Id: tx37ea34dcd1ed48ca9bc7d-0052d84b6f
Date: Thu, 16 Jan 2014 21:13:19 GMT
Date: Thu, 16 Jan 2014 21:13:19 GMT
10 changes: 7 additions & 3 deletions tests/unit/ObjectStore/v1/Models/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ public function test_Get_Metadata()
{
$this->setupMock('HEAD', self::CONTAINER . '/' . self::NAME, null, [], 'HEAD_Object');

$this->assertEquals(['Book' => 'GoodbyeColumbus'], $this->object->getMetadata());
$this->assertEquals([
'Book' => 'GoodbyeColumbus',
'Manufacturer' => 'Acme',
], $this->object->getMetadata());
}

public function test_Merge_Metadata()
{
$this->setupMock('HEAD', self::CONTAINER . '/' . self::NAME, null, [], 'HEAD_Object');

$headers = [
'X-Object-Meta-Author' => 'foo',
'X-Object-Meta-Book' => 'GoodbyeColumbus',
'X-Object-Meta-Author' => 'foo',
'X-Object-Meta-Book' => 'GoodbyeColumbus',
'X-Object-Meta-Manufacturer' => 'Acme',
];

$this->setupMock('POST', self::CONTAINER . '/' . self::NAME, null, $headers, 'NoContent');
Expand Down