Skip to content

Commit

Permalink
use foundationhttpclient in auth when applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
atierian committed Sep 19, 2023
1 parent 8945893 commit cb52039
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import AWSPluginsCore
import ClientRuntime
@_spi(FoundationHTTPClientEngine) import AWSPluginsCore

extension AWSCognitoAuthPlugin {

Expand Down Expand Up @@ -92,9 +93,18 @@ extension AWSCognitoAuthPlugin {
)

if var httpClientEngineProxy = httpClientEngineProxy {
let sdkEngine = configuration.httpClientEngine
httpClientEngineProxy.target = sdkEngine
let httpClientEngine: HttpClientEngine
#if os(watchOS) || os(tvOS)
httpClientEngine = FoundationHTTPClient()
#else
httpClientEngine = configuration.httpClientEngine
#endif
httpClientEngineProxy.target = httpClientEngine
configuration.httpClientEngine = httpClientEngineProxy
} else {
#if os(watchOS) || os(tvOS)
configuration.httpClientEngine = FoundationHTTPClient()
#endif
}

return CognitoIdentityProviderClient(config: configuration)
Expand All @@ -110,6 +120,11 @@ extension AWSCognitoAuthPlugin {
frameworkMetadata: AmplifyAWSServiceConfiguration.frameworkMetaData(),
region: identityPoolConfig.region
)

#if os(watchOS) || os(tvOS)
configuration.httpClientEngine = FoundationHTTPClient()
#endif

return CognitoIdentityClient(config: configuration)
default:
fatalError()
Expand Down

0 comments on commit cb52039

Please sign in to comment.