From ebeb26991aad88d6582366857513f2eef7bb75f3 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 11 Mar 2024 18:18:27 +0800 Subject: [PATCH] Fix consume not updated Signed-off-by: Xuanwo --- core/src/raw/http_util/body.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/raw/http_util/body.rs b/core/src/raw/http_util/body.rs index 38f509c60634..ac0174090db8 100644 --- a/core/src/raw/http_util/body.rs +++ b/core/src/raw/http_util/body.rs @@ -164,15 +164,6 @@ impl IncomingAsyncBody { } impl oio::Read for IncomingAsyncBody { - async fn seek(&mut self, pos: io::SeekFrom) -> Result { - let _ = pos; - - Err(Error::new( - ErrorKind::Unsupported, - "output reader doesn't support seeking", - )) - } - async fn read(&mut self, size: usize) -> Result { if self.size == Some(0) { return Ok(Bytes::new()); @@ -191,7 +182,18 @@ impl oio::Read for IncomingAsyncBody { }; } - let bs = self.chunk.split_to(min(size, self.chunk.len())); + let size = min(size, self.chunk.len()); + self.consumed += size as u64; + let bs = self.chunk.split_to(size); Ok(bs) } + + async fn seek(&mut self, pos: io::SeekFrom) -> Result { + let _ = pos; + + Err(Error::new( + ErrorKind::Unsupported, + "output reader doesn't support seeking", + )) + } }