mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
remove unspecified condition, skip handle the chunk on zero bytes received
This commit is contained in:
parent
62f53304aa
commit
bb8c2273d4
1 changed files with 7 additions and 7 deletions
|
|
@ -55,9 +55,16 @@ pub fn for_memory_input_stream_async(
|
|||
Ok(bytes) => {
|
||||
let len = bytes.len(); // calculate once
|
||||
|
||||
// is the end of stream
|
||||
if len == 0 {
|
||||
return on_complete(Ok((memory_input_stream, total)));
|
||||
}
|
||||
|
||||
// handle the chunk
|
||||
total += len;
|
||||
on_chunk(len, total);
|
||||
|
||||
// push bytes into the memory pool
|
||||
memory_input_stream.add_bytes(&bytes);
|
||||
|
||||
// prevent memory overflow on size `limit` reached
|
||||
|
|
@ -67,13 +74,6 @@ pub fn for_memory_input_stream_async(
|
|||
return on_complete(Err(Error::BytesTotal(memory_input_stream, total, limit)));
|
||||
}
|
||||
|
||||
// is the next iteration required?
|
||||
if len < chunk // some servers may close the connection after first chunk request (@TODO this condition wants review)
|
||||
|| len == 0
|
||||
{
|
||||
return on_complete(Ok((memory_input_stream, total)));
|
||||
}
|
||||
|
||||
// continue reading..
|
||||
for_memory_input_stream_async(
|
||||
memory_input_stream,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue