Skip to content

Commit 5cbd0be

Browse files
committed
Simplify string partition and removed aws request
1 parent 1d57672 commit 5cbd0be

File tree

2 files changed

+9
-49
lines changed

2 files changed

+9
-49
lines changed

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

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -617,62 +617,23 @@ void AWSAuthV4Signer::UpdateUserAgentWithCredentialFeatures(Aws::Http::HttpReque
617617
return;
618618
}
619619

620-
// Get existing User-Agent
621-
Aws::String existingUA = request.GetHeaderValue(USER_AGENT);
622-
623-
// Build credential metrics string
624-
Aws::StringStream credentialMetrics;
625-
bool firstFeature = true;
626-
620+
// Build credential features string
621+
Aws::StringStream credentialFeatures;
627622
for (const auto& feature : features) {
628-
char featureChar = 0;
629623
switch (feature) {
630624
case Aws::Client::UserAgentFeature::CREDENTIALS_ENV_VARS:
631-
featureChar = 'g';
625+
credentialFeatures << "g";
632626
break;
633-
// Add other credential feature mappings as needed
634627
default:
635-
continue; // Skip non-credential features
636-
}
637-
638-
if (!firstFeature) {
639-
credentialMetrics << ",";
628+
// Skip non-credential features
629+
break;
640630
}
641-
credentialMetrics << featureChar;
642-
firstFeature = false;
643631
}
644632

645-
if (credentialMetrics.str().empty()) {
646-
return;
647-
}
648-
649-
// Parse and update existing User-Agent
650-
bool metricsUpdated = false;
633+
// Append credential features to existing UA
634+
Aws::String existingUA = request.GetHeaderValue(USER_AGENT);
651635
Aws::StringStream updatedUA;
652-
const auto parts = Aws::Utils::StringUtils::Split(existingUA, ' ');
636+
updatedUA << existingUA << " m/" << credentialFeatures.str();
653637

654-
for (size_t i = 0; i < parts.size(); ++i) {
655-
if (i > 0) {
656-
updatedUA << ' ';
657-
}
658-
659-
if (parts[i].find("m/") == 0) {
660-
// Add credentials to business metrics
661-
updatedUA << parts[i];
662-
if (!parts[i].empty() && parts[i].back() != '/') {
663-
updatedUA << ',';
664-
}
665-
updatedUA << credentialMetrics.str();
666-
metricsUpdated = true;
667-
} else {
668-
updatedUA << parts[i];
669-
}
670-
}
671-
672-
// If no metrics section found, add one
673-
if (!metricsUpdated) {
674-
updatedUA << " m/" << credentialMetrics.str();
675-
}
676-
677638
request.SetUserAgent(updatedUA.str());
678639
}

src/aws-cpp-sdk-core/source/client/AWSClient.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ HttpResponseOutcome AWSClient::AttemptOneRequest(const std::shared_ptr<Aws::Http
579579

580580
auto signer = GetSignerByName(signerName);
581581
auto signedRequest = TracingUtils::MakeCallWithTiming<bool>([&]() -> bool {
582-
// Use request-aware signing for credential tracking
583-
return signer->SignRequest(*httpRequest, const_cast<Aws::AmazonWebServiceRequest&>(request), signerRegionOverride, signerServiceNameOverride, true);
582+
return signer->SignRequest(*httpRequest, signerRegionOverride, signerServiceNameOverride, true);
584583
},
585584
TracingUtils::SMITHY_CLIENT_SIGNING_METRIC,
586585
*m_telemetryProvider->getMeter(this->GetServiceClientName(), {}),

0 commit comments

Comments
 (0)