Skip to content
Open
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: 4 additions & 2 deletions Storage/src/Connection/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ public function headObject(array $args = []): array
'prettyPrint' => false,
];

$args['retryStrategy'] ??= $this->retryStrategy;

$args['restRetryFunction'] = $this->restRetryFunction ?? $this->getRestRetryFunction(
'objects',
'get',
$args
);

$args += array_filter([
'retryStrategy' => $this->retryStrategy,
'restDelayFunction' => $this->restDelayFunction,
'restCalcDelayFunction' => $this->restCalcDelayFunction,
'restRetryListener' => $this->restRetryListener,
Expand Down Expand Up @@ -1020,14 +1021,15 @@ public function send($resource, $method, array $options = [], $whitelisted = fal
];
$retryResource = isset($retryMap[$resource]) ? $retryMap[$resource] : $resource;

$options['retryStrategy'] ??= $this->retryStrategy;

$options['restRetryFunction'] = $this->restRetryFunction ?? $this->getRestRetryFunction(
$retryResource,
$method,
$options
);

$options += array_filter([
'retryStrategy' => $this->retryStrategy,
'restDelayFunction' => $this->restDelayFunction,
'restCalcDelayFunction' => $this->restCalcDelayFunction,
'restRetryListener' => $this->restRetryListener,
Expand Down
9 changes: 5 additions & 4 deletions Storage/tests/Unit/StorageClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,20 +612,20 @@ public function testDefaultRetryStrategyFailing()
$client->createBucket('myBucket');
}

public static function getCreateBucketSuccessResponse()
public static function getCreateHmacKeySuccessResponse()
{
return new Response(
200,
['Content-Type' => 'application/json'],
json_encode(['name' => 'myBucket'])
json_encode(['secret' => 'foo', 'metadata' => ['accessId' => 'test']])
);
}

public function testAlwaysRetryStrategySuccessful()
{
$httpHandler = self::getHttpHandlerMock([
new Response(503), // Service Unavailable
self::getCreateBucketSuccessResponse(),
self::getCreateHmacKeySuccessResponse(),
])[1];

$client = new StorageClient([
Expand All @@ -642,7 +642,8 @@ public function testAlwaysRetryStrategySuccessful()
},
]);

$this->assertInstanceOf(Bucket::class, $client->createBucket('myBucket'));
// Test using an operation that is not idempotent
$this->assertInstanceOf(CreatedHmacKey::class, $client->createHmacKey('test@example.com'));
}

public function testDelayFunctionsConfiguration()
Expand Down
Loading