Skip to content

Commit fca4b57

Browse files
committed
fix for custom UA
1 parent 27bb163 commit fca4b57

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,33 @@ namespace Aws
3838
return m_features;
3939
}
4040

41+
/**
42+
* Set the user agent for this context
43+
*/
44+
void SetUserAgent(const std::shared_ptr<Aws::Client::UserAgent>& userAgent)
45+
{
46+
m_userAgent = userAgent;
47+
}
48+
49+
/**
50+
* Get the user agent associated with this context
51+
*/
52+
const std::shared_ptr<Aws::Client::UserAgent>& GetUserAgent() const
53+
{
54+
return m_userAgent;
55+
}
56+
57+
/**
58+
* Check if this context has a custom user agent
59+
*/
60+
bool HasCustomUserAgent() const
61+
{
62+
return m_userAgent && m_userAgent->HasOverrideUserAgent();
63+
}
64+
4165
private:
4266
Aws::Set<Aws::Client::UserAgentFeature> m_features;
67+
std::shared_ptr<Aws::Client::UserAgent> m_userAgent;
4368
};
4469

4570
/**

src/aws-cpp-sdk-core/include/aws/core/client/UserAgent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class AWS_CORE_API UserAgent {
4040
static Aws::String BusinessMetricForFeature(UserAgentFeature feature);
4141
explicit UserAgent(const ClientConfiguration& clientConfiguration, const Aws::String& retryStrategyName, const Aws::String& apiName);
4242
Aws::String SerializeWithFeatures(const Aws::Set<UserAgentFeature>& features) const;
43+
44+
bool HasOverrideUserAgent() const { return !m_overrideUserAgent.empty(); }
4345
void SetApiName(const Aws::String& apiName) { m_api = apiName; }
4446
void AddLegacyFeature(const Aws::String& legacyFeature);
4547

src/aws-cpp-sdk-core/source/auth/signer/AWSAuthV4Signer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ void AWSAuthV4Signer::UpdateUserAgentWithCredentialFeatures(Aws::Http::HttpReque
612612
return;
613613
}
614614

615+
if (context.HasCustomUserAgent()) {
616+
AWS_LOGSTREAM_DEBUG(v4LogTag, "Custom User-Agent detected, skipping credential feature update");
617+
return;
618+
}
619+
615620
const auto features = context.GetUserAgentFeatures();
616621
if (features.empty()) {
617622
AWS_LOGSTREAM_DEBUG(v4LogTag, "No credential features to add to User-Agent");

0 commit comments

Comments
 (0)