Skip to content

Commit 06bdb6c

Browse files
committed
Check for UA overwrite
1 parent 2d7a82d commit 06bdb6c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,34 @@ 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+
65+
4166
private:
4267
Aws::Set<Aws::Client::UserAgentFeature> m_features;
68+
std::shared_ptr<Aws::Client::UserAgent> m_userAgent;
4369
};
4470

4571
/**

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)