diff --git a/Storage/src/Connection/Rest.php b/Storage/src/Connection/Rest.php index 02acc0867fd2..876e9e5665c0 100644 --- a/Storage/src/Connection/Rest.php +++ b/Storage/src/Connection/Rest.php @@ -317,6 +317,8 @@ public function headObject(array $args = []): array 'prettyPrint' => false, ]; + $args['retryStrategy'] ??= $this->retryStrategy; + $args['restRetryFunction'] = $this->restRetryFunction ?? $this->getRestRetryFunction( 'objects', 'get', @@ -324,7 +326,6 @@ public function headObject(array $args = []): array ); $args += array_filter([ - 'retryStrategy' => $this->retryStrategy, 'restDelayFunction' => $this->restDelayFunction, 'restCalcDelayFunction' => $this->restCalcDelayFunction, 'restRetryListener' => $this->restRetryListener, @@ -1020,6 +1021,8 @@ 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, @@ -1027,7 +1030,6 @@ public function send($resource, $method, array $options = [], $whitelisted = fal ); $options += array_filter([ - 'retryStrategy' => $this->retryStrategy, 'restDelayFunction' => $this->restDelayFunction, 'restCalcDelayFunction' => $this->restCalcDelayFunction, 'restRetryListener' => $this->restRetryListener, diff --git a/Storage/tests/Unit/StorageClientTest.php b/Storage/tests/Unit/StorageClientTest.php index 9fc8c7bf6892..84b1e007c3fd 100644 --- a/Storage/tests/Unit/StorageClientTest.php +++ b/Storage/tests/Unit/StorageClientTest.php @@ -612,12 +612,12 @@ 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']]) ); } @@ -625,7 +625,7 @@ public function testAlwaysRetryStrategySuccessful() { $httpHandler = self::getHttpHandlerMock([ new Response(503), // Service Unavailable - self::getCreateBucketSuccessResponse(), + self::getCreateHmacKeySuccessResponse(), ])[1]; $client = new StorageClient([ @@ -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()