From 90345e090c0be0cff9f0d22bd182c0bd461e9df2 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Mon, 22 Jun 2020 18:24:09 -0700 Subject: [PATCH] fix the number of bytes that are read by stream (#203) --- sdk/core/azure-core/src/http/curl/curl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 90a39aea5..cacce1a55 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -276,6 +276,9 @@ uint64_t CurlSession::ReadWithOffset(uint8_t* buffer, uint64_t bufferSize, uint6 // Set the max to be written as the size of remaining body size auto bytesToWrite = std::min<>(bufferSize, remainingBodySize); + // total of bytes read (any from inner buffer plus any from socket) + uint64_t bytesRead = uint64_t(); + // If bodyStartInBuffer is set and while innerBufferStart is less than the buffer, it means there // is still data at innerbuffer for the body that is not yet read if (this->m_bodyStartInBuffer > 0 && LibcurlReaderSize > innerBufferStart) @@ -311,10 +314,11 @@ uint64_t CurlSession::ReadWithOffset(uint8_t* buffer, uint64_t bufferSize, uint6 // to write writePosition += innerbufferSize; bytesToWrite -= innerbufferSize; + bytesRead += innerbufferSize; } // read from socket the remaining requested bytes - auto bytesRead = ReadSocketToBuffer(writePosition, (size_t)bytesToWrite); + bytesRead += ReadSocketToBuffer(writePosition, (size_t)bytesToWrite); if (remainingBodySize - bytesRead == 0) { // No more to read from socket