Skip to content

Commit 4e6d999

Browse files
authored
[Pick][0.6 to 0.7] fix(http): fix chunked transfer encoding (alibaba#1115)
* fix(http): Fix stale buffer data being parsed in chunked transfer encoding Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * fix(http): prevent duplicate stream read in chunked body when parsing final chunk Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> --------- Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>
1 parent 43c27ff commit 4e6d999

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net/http/body.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class ChunkedBodyReadStream : public BodyReadStream {
127127
// Quote from rfc2616#section-3.6.1: The chunk-size field is a string of hex digits
128128
// indicating the size of the chunk.
129129
m_chunked_remain = line.substr(0, p).hex_to_uint64();
130+
m_cursor += p + 2;
130131
if (m_chunked_remain != 0 || p == 0) {
131-
m_cursor += p + 2;
132132
return true;
133133
}
134134
m_finish = true;
@@ -189,6 +189,8 @@ class ChunkedBodyReadStream : public BodyReadStream {
189189
m_line_size -= m_cursor;
190190
m_cursor = 0;
191191
}
192+
} else if (m_cursor == m_line_size) { // reset
193+
m_cursor = m_line_size = 0;
192194
}
193195

194196
bool get_line_finish = false;

0 commit comments

Comments
 (0)