@@ -390,17 +390,6 @@ HttpResponseOutcome AWSClient::AttemptExhaustively(const Aws::Http::URI& uri,
390390 {
391391 newUri.SetAuthority (newEndpoint);
392392 }
393-
394- // Save checksum information from the original request if we haven't already - safe to assume that the checksum has been finalized, since we have sent and received a response
395- RetryContext context = request.GetRetryContext ();
396- if (context.m_requestHash == nullptr ) {
397- auto originalRequestHash = httpRequest->GetRequestHash ();
398- if (originalRequestHash.second != nullptr ) {
399- context.m_requestHash = Aws::MakeShared<std::pair<Aws::String, std::shared_ptr<Aws::Utils::Crypto::Hash>>>(AWS_CLIENT_LOG_TAG, originalRequestHash);
400- request.SetRetryContext (context);
401- }
402- }
403-
404393 httpRequest = CreateHttpRequest (newUri, method, request.GetResponseStreamFactory ());
405394
406395 httpRequest->SetHeaderValue (Http::SDK_INVOCATION_ID_HEADER, invocationId);
@@ -577,12 +566,6 @@ HttpResponseOutcome AWSClient::AttemptOneRequest(const std::shared_ptr<Aws::Http
577566 }
578567 }
579568
580- // Track credential provider usage for User-Agent features
581- auto credentialsProvider = GetCredentialsProvider ();
582- if (credentialsProvider) {
583- credentialsProvider->GetAWSCredentials (const_cast <Aws::AmazonWebServiceRequest&>(request));
584- }
585-
586569 auto signer = GetSignerByName (signerName);
587570 auto signedRequest = TracingUtils::MakeCallWithTiming<bool >([&]() -> bool {
588571 return signer->SignRequest (*httpRequest, signerRegionOverride, signerServiceNameOverride, true );
@@ -596,6 +579,12 @@ HttpResponseOutcome AWSClient::AttemptOneRequest(const std::shared_ptr<Aws::Http
596579 return HttpResponseOutcome (AWSError<CoreErrors>(CoreErrors::CLIENT_SIGNING_FAILURE, " " , " SDK failed to sign the request" , false /* retryable*/ ));
597580 }
598581
582+ // Track credential provider usage for User-Agent features
583+ auto credentialsProvider = GetCredentialsProvider ();
584+ if (credentialsProvider) {
585+ credentialsProvider->GetAWSCredentials (const_cast <Aws::AmazonWebServiceRequest&>(request));
586+ }
587+
599588 if (request.GetRequestSignedHandler ())
600589 {
601590 request.GetRequestSignedHandler ()(*httpRequest);
@@ -938,13 +927,6 @@ void AWSClient::BuildHttpRequest(const Aws::AmazonWebServiceRequest& request, co
938927 httpRequest->SetContinueRequestHandle (request.GetContinueRequestHandler ());
939928 httpRequest->SetServiceSpecificParameters (request.GetServiceSpecificParameters ());
940929 request.AddQueryStringParameters (httpRequest->GetUri ());
941-
942- // check for retry context, if present use it
943- RetryContext context = request.GetRetryContext ();
944- if (context.m_requestHash != nullptr ) {
945- const auto hash = Aws::MakeShared<Aws::Utils::Crypto::PrecalculatedHash>(smithy::client::AWS_SMITHY_CLIENT_CHECKSUM, HashingUtils::Base64Encode (context.m_requestHash ->second ->GetHash ().GetResult ()));
946- httpRequest->SetRequestHash (context.m_requestHash ->first , hash);
947- }
948930}
949931
950932Aws::String AWSClient::GeneratePresignedUrl (const Aws::Http::URI& uri, Aws::Http::HttpMethod method, long long expirationInSeconds, const std::shared_ptr<Aws::Http::ServiceSpecificParameters> serviceSpecificParameter)
@@ -1035,37 +1017,38 @@ std::shared_ptr<Aws::Http::HttpResponse> AWSClient::MakeHttpRequest(std::shared_
10351017 return m_httpClient->MakeRequest (request, m_readRateLimiter.get (), m_writeRateLimiter.get ());
10361018}
10371019
1038- void AWSClient::AppendRecursionDetectionHeader (std::shared_ptr<Aws::Http::HttpRequest> ioRequest) {
1039- if (!ioRequest || ioRequest->HasHeader (Aws::Http::X_AMZN_TRACE_ID_HEADER)) {
1040- return ;
1041- }
1042- Aws::String awsLambdaFunctionName = Aws::Environment::GetEnv (AWS_LAMBDA_FUNCTION_NAME);
1043- if (awsLambdaFunctionName.empty ()) {
1044- return ;
1045- }
1046- Aws::String xAmznTraceIdVal = Aws::Environment::GetEnv (X_AMZN_TRACE_ID);
1047- if (xAmznTraceIdVal.empty ()) {
1048- return ;
1049- }
1050-
1051- // Escape all non-printable ASCII characters by percent encoding
1052- Aws::OStringStream xAmznTraceIdValEncodedStr;
1053- for (const char ch : xAmznTraceIdVal)
1054- {
1055- if (ch >= 0x20 && ch <= 0x7e ) // ascii chars [32-126] or [' ' to '~'] are not escaped
1056- {
1057- xAmznTraceIdValEncodedStr << ch;
1020+ void AWSClient::AppendRecursionDetectionHeader (std::shared_ptr<Aws::Http::HttpRequest> ioRequest)
1021+ {
1022+ if (!ioRequest || ioRequest->HasHeader (Aws::Http::X_AMZN_TRACE_ID_HEADER)) {
1023+ return ;
10581024 }
1059- else
1025+ Aws::String awsLambdaFunctionName = Aws::Environment::GetEnv (AWS_LAMBDA_FUNCTION_NAME);
1026+ if (awsLambdaFunctionName.empty ()) {
1027+ return ;
1028+ }
1029+ Aws::String xAmznTraceIdVal = Aws::Environment::GetEnv (X_AMZN_TRACE_ID);
1030+ if (xAmznTraceIdVal.empty ()) {
1031+ return ;
1032+ }
1033+
1034+ // Escape all non-printable ASCII characters by percent encoding
1035+ Aws::OStringStream xAmznTraceIdValEncodedStr;
1036+ for (const char ch : xAmznTraceIdVal)
10601037 {
1061- // A percent-encoded octet is encoded as a character triplet
1062- xAmznTraceIdValEncodedStr << ' %' // consisting of the percent character "%"
1063- << std::hex << std::setfill (' 0' ) << std::setw (2 ) << std::uppercase
1064- << (size_t ) ch // followed by the two hexadecimal digits representing that octet's numeric value
1065- << std::dec << std::setfill (' ' ) << std::setw (0 ) << std::nouppercase;
1038+ if (ch >= 0x20 && ch <= 0x7e ) // ascii chars [32-126] or [' ' to '~'] are not escaped
1039+ {
1040+ xAmznTraceIdValEncodedStr << ch;
1041+ }
1042+ else
1043+ {
1044+ // A percent-encoded octet is encoded as a character triplet
1045+ xAmznTraceIdValEncodedStr << ' %' // consisting of the percent character "%"
1046+ << std::hex << std::setfill (' 0' ) << std::setw (2 ) << std::uppercase
1047+ << (size_t ) ch // followed by the two hexadecimal digits representing that octet's numeric value
1048+ << std::dec << std::setfill (' ' ) << std::setw (0 ) << std::nouppercase;
1049+ }
10661050 }
1067- }
1068- xAmznTraceIdVal = xAmznTraceIdValEncodedStr.str ();
1051+ xAmznTraceIdVal = xAmznTraceIdValEncodedStr.str ();
10691052
1070- ioRequest->SetHeaderValue (Aws::Http::X_AMZN_TRACE_ID_HEADER, xAmznTraceIdVal);
1053+ ioRequest->SetHeaderValue (Aws::Http::X_AMZN_TRACE_ID_HEADER, xAmznTraceIdVal);
10711054}
0 commit comments