Skip to content

Commit 774075c

Browse files
committed
fix reviews on awschunking and default behavior
1 parent b449d40 commit 774075c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/aws-cpp-sdk-core/include/smithy/client/features/ChunkingInterceptor.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,20 @@ class AwsChunkedStreamBuf : public std::streambuf {
3838
if (gptr() < egptr()) {
3939
return traits_type::to_int_type(*gptr());
4040
}
41-
42-
if (m_stream->good()) {
43-
m_stream->read(m_data.GetUnderlyingData(), m_bufferSize);
44-
size_t bytesRead = static_cast<size_t>(m_stream->gcount());
45-
writeChunk(bytesRead);
46-
47-
if ((m_stream->peek() == EOF || m_stream->eof()) && !m_stream->bad()) {
48-
writeTrailerToUnderlyingStream();
49-
}
50-
}
5141

42+
// Only read from source stream if chunking stream is empty
5243
if ((m_chunkingStream->peek() == EOF || m_chunkingStream->eof()) && !m_chunkingStream->bad()) {
53-
return traits_type::eof();
44+
if (m_stream->good()) {
45+
m_stream->read(m_data.GetUnderlyingData(), m_bufferSize);
46+
size_t bytesRead = static_cast<size_t>(m_stream->gcount());
47+
writeChunk(bytesRead);
48+
49+
if ((m_stream->peek() == EOF || m_stream->eof()) && !m_stream->bad()) {
50+
writeTrailerToUnderlyingStream();
51+
}
52+
} else {
53+
return traits_type::eof();
54+
}
5455
}
5556

5657
m_chunkingStream->read(m_buffer, sizeof(m_buffer));

0 commit comments

Comments
 (0)