@@ -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}
0 commit comments