-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
777 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
#include <aws/core/client/ClientConfiguration.h> | ||
#include <aws/core/client/RetryStrategy.h> | ||
#include <aws/core/utils/memory/stl/AWSSet.h> | ||
|
||
namespace Aws { | ||
namespace Client { | ||
|
||
enum class UserAgentFeature { | ||
RETRY_MODE_LEGACY, | ||
RETRY_MODE_STANDARD, | ||
RETRY_MODE_ADAPTIVE, | ||
S3_TRANSFER, | ||
S3_CRYPTO_V1N, | ||
S3_CRYPTO_V2, | ||
}; | ||
|
||
class AWS_CORE_API UserAgent { | ||
public: | ||
explicit UserAgent(const ClientConfiguration& clientConfiguration, const Aws::String& retryStrategyName, const Aws::String& apiName); | ||
Aws::String SerializeWithFeatures(const Aws::Set<UserAgentFeature>& features) const; | ||
void SetApiName(const Aws::String& apiName) { m_api = apiName; } | ||
void AddLegacyFeature(const Aws::String& legacyFeature); | ||
|
||
private: | ||
const Aws::String m_sdkVersion; | ||
const Aws::String m_userAgentVersion; | ||
Aws::String m_api; | ||
const Aws::String m_crtVersion; | ||
const Aws::String m_osVersion; | ||
const Aws::String m_archName; | ||
const Aws::String m_cppVersion; | ||
const Aws::String m_compilerMetadata; | ||
const Aws::String m_retryStrategyName; | ||
const Aws::String m_execEnv; | ||
const Aws::String m_appId; | ||
const Aws::String m_customizations; | ||
Aws::Set<UserAgentFeature> m_features; | ||
}; | ||
} // namespace Client | ||
} // namespace Aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/aws-cpp-sdk-core/include/smithy/client/features/UserAgentInterceptor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <aws/core/client/ClientConfiguration.h> | ||
#include <aws/core/client/RetryStrategy.h> | ||
#include <aws/core/client/UserAgent.h> | ||
#include <smithy/interceptor/Interceptor.h> | ||
|
||
#include <utility> | ||
|
||
namespace smithy { | ||
namespace client { | ||
class UserAgentInterceptor : public interceptor::Interceptor { | ||
public: | ||
explicit UserAgentInterceptor(const Aws::Client::ClientConfiguration& configuration, | ||
const Aws::String& retryStrategyName, | ||
const Aws::String& apiName) | ||
: m_userAgent{configuration, retryStrategyName, apiName} {}; | ||
UserAgentInterceptor(const UserAgentInterceptor& other) = delete; | ||
UserAgentInterceptor(UserAgentInterceptor&& other) noexcept = default; | ||
UserAgentInterceptor& operator=(const UserAgentInterceptor& other) = delete; | ||
UserAgentInterceptor& operator=(UserAgentInterceptor&& other) noexcept = delete; | ||
|
||
ModifyRequestOutcome ModifyBeforeSigning(interceptor::InterceptorContext& context) override { | ||
auto transmitRequest = context.GetTransmitRequest(); | ||
assert(transmitRequest); | ||
transmitRequest->SetUserAgent(m_userAgent.SerializeWithFeatures(context.GetModeledRequest().GetUserAgentFeatures())); | ||
return transmitRequest; | ||
} | ||
|
||
ModifyResponseOutcome ModifyBeforeDeserialization(interceptor::InterceptorContext& context) override { | ||
return context.GetTransmitResponse(); | ||
} | ||
|
||
void SetApiName(const Aws::String& apiName) { m_userAgent.SetApiName(apiName); } | ||
|
||
void AddLegacyFeaturesToUserAgent(const Aws::String& valueToAppend) { m_userAgent.AddLegacyFeature(valueToAppend); } | ||
|
||
private: | ||
Aws::Client::UserAgent m_userAgent; | ||
}; | ||
} // namespace client | ||
} // namespace smithy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.