88use Aws \Retry \ConfigurationInterface ;
99use Aws \Retry \RateLimiter ;
1010use Aws \Retry \RetryHelperTrait ;
11- use GuzzleHttp \Exception \RequestException ;
1211use GuzzleHttp \Promise ;
1312use GuzzleHttp \Promise \PromiseInterface ;
1413use Psr \Http \Message \RequestInterface ;
@@ -72,7 +71,6 @@ class RetryMiddleware
7271 private array $ options ;
7372 private QuotaManager $ quotaManager ;
7473 private ?RateLimiter $ rateLimiter = null ;
75- private array $ retryCurlErrors ;
7674 private ?string $ service ;
7775
7876 public static function wrap (ConfigurationInterface $ config , array $ options ): \Closure
@@ -84,23 +82,17 @@ public static function wrap(ConfigurationInterface $config, array $options): \Cl
8482
8583 /**
8684 * Returns a closure that decides retryability for a given result based
87- * on the standard error codes, status codes, and curl errors. Quota and
88- * max-attempts decisions are handled by the middleware itself, not by
89- * this closure.
85+ * on the standard error codes and status codes. Quota and max-attempts
86+ * decisions are handled by the middleware itself, not by this closure.
9087 */
9188 public static function createDefaultDecider (array $ options = []): \Closure
9289 {
93- $ retryCurlErrors = [];
94- if (extension_loaded ('curl ' )) {
95- $ retryCurlErrors [CURLE_RECV_ERROR ] = true ;
96- }
97-
9890 return function (
9991 int $ attempts ,
10092 CommandInterface $ command ,
10193 mixed $ result
102- ) use ($ options, $ retryCurlErrors ): bool {
103- return self ::isRetryable ($ result , $ retryCurlErrors , $ options );
94+ ) use ($ options ): bool {
95+ return self ::isRetryable ($ result , $ options );
10496 };
10597 }
10698
@@ -128,16 +120,6 @@ public function __construct(
128120 ? ($ options ['delayer ' ])(...)
129121 : null ;
130122
131- $ this ->retryCurlErrors = [];
132- if (extension_loaded ('curl ' )) {
133- $ this ->retryCurlErrors [CURLE_RECV_ERROR ] = true ;
134- }
135- if (!empty ($ options ['curl_errors ' ]) && is_array ($ options ['curl_errors ' ])) {
136- foreach ($ options ['curl_errors ' ] as $ code ) {
137- $ this ->retryCurlErrors [$ code ] = true ;
138- }
139- }
140-
141123 if ($ this ->mode === 'adaptive ' ) {
142124 $ this ->rateLimiter = $ options ['rate_limiter ' ] ?? new RateLimiter ();
143125 }
@@ -198,7 +180,6 @@ public function __invoke(CommandInterface $cmd, RequestInterface $req): PromiseI
198180
199181 $ isRetryable = self ::isRetryable (
200182 $ value ,
201- $ this ->retryCurlErrors ,
202183 $ this ->options
203184 );
204185
@@ -342,7 +323,6 @@ private function computeRetryDelay(int $attemptIndex, bool $isThrottling, mixed
342323
343324 private static function isRetryable (
344325 mixed $ result ,
345- array $ retryCurlErrors ,
346326 array $ options = []
347327 ): bool
348328 {
@@ -371,14 +351,6 @@ private static function isRetryable(
371351 }
372352 }
373353
374- if (!empty ($ options ['curl_errors ' ])
375- && is_array ($ options ['curl_errors ' ])
376- ) {
377- foreach ($ options ['curl_errors ' ] as $ code ) {
378- $ retryCurlErrors [$ code ] = true ;
379- }
380- }
381-
382354 $ isError = $ result instanceof \Throwable;
383355
384356 if (!$ isError ) {
@@ -406,24 +378,6 @@ private static function isRetryable(
406378 return true ;
407379 }
408380
409- if (count ($ retryCurlErrors )
410- && ($ previous = $ result ->getPrevious ())
411- && $ previous instanceof RequestException
412- ) {
413- if (method_exists ($ previous , 'getHandlerContext ' )) {
414- $ context = $ previous ->getHandlerContext ();
415- return !empty ($ context ['errno ' ])
416- && isset ($ retryCurlErrors [$ context ['errno ' ]]);
417- }
418-
419- $ message = $ previous ->getMessage ();
420- foreach (array_keys ($ retryCurlErrors ) as $ curlError ) {
421- if (str_starts_with ($ message , 'cURL error ' . $ curlError . ': ' )) {
422- return true ;
423- }
424- }
425- }
426-
427381 if (!empty ($ errorShape = $ result ->getAwsErrorShape ())) {
428382 $ definition = $ errorShape ->toArray ();
429383 if (!empty ($ definition ['retryable ' ])) {
0 commit comments