# reqwest_client: Fix streamed request bodies being truncated \(\#60314\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/552fc9f3c3c775276c2ce3f0fb93f1f4c2c18ba6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 552fc9f3c3c775276c2ce3f0fb93f1f4c2c18ba6

Requested commit: 552fc9f3c3c775276c2ce3f0fb93f1f4c2c18ba6

Commit: 552fc9f3c3c775276c2ce3f0fb93f1f4c2c18ba6

Tree: 81dff3120bb319b9f68c6010dc799567ae16d589

Author: Ben Kunkle

Committer: GitHub

## Message

```
reqwest_client: Fix streamed request bodies being truncated (#60314)

StreamReader::poll_next dropped the reader it take()s whenever the read
returned Poll::Pending, so the next poll reported end-of-stream. And
poll_read_buf measured bytes via ReadBuf::filled(), which never advances
when the reader writes through initialize_unfilled(), so every read
counted as zero bytes. Together these made any AsyncBody::from_reader
request body (e.g. one backed by async_fs::File, which returns Pending
on its first read) upload as an empty or truncated body.

Keep the reader across Pending polls and use the byte count that
futures::AsyncRead::poll_read returns.



- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
```

## Parents

- [b5c2d8a13f395bbdbaf9cb74bda16bbcb00414d1](https://git.cafe/gitcafe/zed/commit/b5c2d8a13f395bbdbaf9cb74bda16bbcb00414d1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/552fc9f3c3c775276c2ce3f0fb93f1f4c2c18ba6?format=markdown)
