Skip to content

Commit 1a144f5

Browse files
authored
Fix response checksum stringstream usage (#3967)
* Avoid per-chunk std::stringstream in response checksum header lookup * changelog
1 parent 74c7d5e commit 1a144f5

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "aws-cpp-sdk-core",
4+
"contributor": "sbaluja",
5+
"description": "Avoid per-chunk std::stringstream in response checksum header lookup"
6+
}

‎src/aws-cpp-sdk-core/source/http/crt/CRTHttpClient.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ void OnResponseBodyReceived(Aws::Crt::Http::HttpStream&, const Aws::Crt::ByteCur
6060
const std::shared_ptr<Aws::Http::HttpRequest>& request) {
6161
assert(response);
6262
for (const auto& hashIterator : request->GetResponseValidationHashes()) {
63-
std::stringstream headerStr;
64-
headerStr << "x-amz-checksum-" << hashIterator.first;
65-
if (response->HasHeader(headerStr.str().c_str())) {
63+
if (response->HasHeader(("x-amz-checksum-" + hashIterator.first).c_str())) {
6664
hashIterator.second->Update(reinterpret_cast<unsigned char*>(body.ptr), body.len);
6765
break;
6866
}

‎src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ static size_t WriteData(char* ptr, size_t size, size_t nmemb, void* userdata)
203203

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

‎src/aws-cpp-sdk-core/source/http/windows/WinSyncHttpClient.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,7 @@ bool WinSyncHttpClient::BuildSuccessResponse(const std::shared_ptr<HttpRequest>&
249249
{
250250
for (const auto& hashIterator : request->GetResponseValidationHashes())
251251
{
252-
std::stringstream headerStr;
253-
headerStr<<"x-amz-checksum-"<<hashIterator.first;
254-
if(response->HasHeader(headerStr.str().c_str()))
252+
if(response->HasHeader(("x-amz-checksum-" + hashIterator.first).c_str()))
255253
{
256254
hashIterator.second->Update(reinterpret_cast<unsigned char*>(dst), static_cast<size_t>(read));
257255
break;

0 commit comments

Comments
 (0)