Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/aws-cpp-sdk-core/source/http/crt/CRTHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,19 @@ namespace Aws
}

//TODO: handle the read rate limiter here, once back pressure is setup.
assert(response);
for (const auto& hashIterator : request->GetResponseValidationHashes())
Copy link
Copy Markdown
Contributor

@jeking3 jeking3 Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An improvement here would be to delay hash initialization until it's first used, as workloads that use lots of requests on small data sets will have a lower files/s throughput potential if we initialize them all up front.

{
std::stringstream headerStr;
headerStr<<"x-amz-checksum-"<<hashIterator.first;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An improvement here would be to embed the c string representation of the header into the hash class, avoiding a stringstream to string to c string for every buffer that arrives.

if(response->HasHeader(headerStr.str().c_str()))
{
hashIterator.second->Update(reinterpret_cast<unsigned char*>(body.ptr), body.len);
break;
}
}

// When data is received from the content body of the incoming response, just copy it to the output stream.
assert(response);
response->GetResponseBody().write((const char*)body.ptr, static_cast<long>(body.len));
if (response->GetResponseBody().fail()) {
const auto& ref = response->GetResponseBody();
Expand Down
6 changes: 6 additions & 0 deletions src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ static size_t WriteData(char* ptr, size_t size, size_t nmemb, void* userdata)

for (const auto& hashIterator : context->m_request->GetResponseValidationHashes())
{
std::stringstream headerStr;
headerStr<<"x-amz-checksum-"<<hashIterator.first;
if(context->m_response->HasHeader(headerStr.str().c_str()))
{
hashIterator.second->Update(reinterpret_cast<unsigned char*>(ptr), sizeToWrite);
break;
}
}

if (response->GetResponseBody().fail()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,13 @@ bool WinSyncHttpClient::BuildSuccessResponse(const std::shared_ptr<HttpRequest>&
{
for (const auto& hashIterator : request->GetResponseValidationHashes())
{
std::stringstream headerStr;
headerStr<<"x-amz-checksum-"<<hashIterator.first;
if(response->HasHeader(headerStr.str().c_str()))
{
hashIterator.second->Update(reinterpret_cast<unsigned char*>(dst), static_cast<size_t>(read));
break;
}
}

auto& headersHandler = request->GetHeadersReceivedEventHandler();
Expand Down
Loading