ITADN

`ResponseDataStream`: `ReaderStream` vs `.bytes`

#437Openjohnbchron 创建于 2025-10-30
bug
J
johnbchroncommented
**Describe the bug** It looks like the `AsyncRead` implementation on `ResponseDataStream` is incorrect. The only datapoint I have at the moment is that I consistently only get about 1/3 the number of bytes back from reading all of `tokio_util::io::ReaderStream::new(response_data_stream)` vs `response_data_stream.bytes`. Converting a `impl Stream<Item<Result<bytes::Bytes, _>>>` to a `impl AsyncRead` and then reading it should yield all the same bytes as just reading the stream directly, and I'm guessing it's not an issue with the `ReaderStream` implementation. I'll do some more testing. **To Reproduce** ```rust let req = bucket.get_object_stream(key).await.unwrap(); let stream = req.bytes; let mut data = Vec::new(); while let Some(Ok(chunk)) = stream.next().await { data.extend(&chunk[..]); } println!("data.len() = {}", data.len()); // same as before, but now with: let stream = tokio_util::io::ReaderStream::new(req); ``` **Expected behavior** These two options produce the same number of bytes **Environment** - Rust version: `rustc 1.93.0-nightly (f37aa9955 2025-10-26)` - lib version `0.37.0`
0 条评论