From 562b9c9ad1559a5be9e6816295b9a4e65138c4af Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Fri, 8 Nov 2024 13:17:29 -0600 Subject: [PATCH] chore: Remove retry-after header support --- .../Retry/AWSRetryErrorInfoProvider.swift | 18 +++++------------- .../Retry/AWSRetryErrorInfoProviderTests.swift | 14 -------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Retry/AWSRetryErrorInfoProvider.swift b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Retry/AWSRetryErrorInfoProvider.swift index 7661f54b2cc..ac794885b16 100644 --- a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Retry/AWSRetryErrorInfoProvider.swift +++ b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Retry/AWSRetryErrorInfoProvider.swift @@ -55,14 +55,6 @@ public enum AWSRetryErrorInfoProvider: RetryErrorInfoProvider { public static func errorInfo(for error: Error) -> RetryErrorInfo? { - // Look for a header with a retry after value; use it as retry after hint - var retryAfterHint: TimeInterval? - if let headers = (error as? HTTPError)?.httpResponse.headers, - let delayString = headers.value(for: "Retry-After") ?? headers.value(for: "X-Amz-Retry-After"), - let delay = TimeInterval(delayString) { - retryAfterHint = delay - } - // Determine based on properties if this error is a timeout error. var isTimeout = false @@ -75,32 +67,32 @@ public enum AWSRetryErrorInfoProvider: RetryErrorInfoProvider { // Handle certain CRT errors as transient errors if case CommonRunTimeError.crtError(let crtError) = error { if transientCRTErrorCodes.contains(crtError.code) { - return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout) + return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout) } } if let serviceError = error as? ServiceError, let code = serviceError.typeName { // Handle the throttling error codes as errors of retry type "throttling". if throttlingErrorCodes.contains(code) { - return RetryErrorInfo(errorType: .throttling, retryAfterHint: retryAfterHint, isTimeout: false) + return RetryErrorInfo(errorType: .throttling, retryAfterHint: nil, isTimeout: false) } // Handle the transient error codes as errors of retry type "transient". if transientErrorCodes.contains(code) { - return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout) + return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout) } } if let httpError = error as? HTTPError { // Handle the transient and timeout HTTP status codes as errors of retry type "transient". if (transientStatusCodes + timeoutStatusCodes).contains(httpError.httpResponse.statusCode.rawValue) { - return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout) + return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout) } } if let modeledError = error as? ModeledError, type(of: modeledError).typeName == "IDPCommunicationError" { // Handle a modeled IDPCommunicationError (comes from STS) as an error of retry type "transient". - return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout) + return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout) } // If custom AWS error matching fails, use the default error info provider to finish matching. diff --git a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Retry/AWSRetryErrorInfoProviderTests.swift b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Retry/AWSRetryErrorInfoProviderTests.swift index f7b653e7866..c068fc89526 100644 --- a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Retry/AWSRetryErrorInfoProviderTests.swift +++ b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Retry/AWSRetryErrorInfoProviderTests.swift @@ -80,20 +80,6 @@ class AWSRetryErrorInfoProviderTests: XCTestCase { } } - // MARK: - Retry after hint - - func test_retryAfterHint_setsRetryAfterHintWhenRetryAfterHeaderIsSetWithSeconds() throws { - let error = try TestHTTPError(statusCode: 500, headers: ["retry-after": "2.8"]) - let errorInfo = AWSRetryErrorInfoProvider.errorInfo(for: error) - XCTAssertEqual(errorInfo?.retryAfterHint, 2.8) - } - - func test_retryAfterHint_setsRetryAfterHintWhenXAmzRetryAfterHeaderIsSetWithSeconds() throws { - let error = try TestHTTPError(statusCode: 500, headers: ["x-amz-retry-after": "2.7"]) - let errorInfo = AWSRetryErrorInfoProvider.errorInfo(for: error) - XCTAssertEqual(errorInfo?.retryAfterHint, 2.7) - } - // MARK: - isTimeout func test_isTimeout_setsIsTimeoutWhenHTTPStatusCodeIndicatesTimeout() throws {