seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.42k stars 1.05k forks source link

`Sync` bound in `Body::wrap_stream` back after `v0.12.0` #2273

Open ikai104 opened 2 months ago

ikai104 commented 2 months ago

Sync bound in Body::wrap_stream() had removed since #2088 (v0.11.24) but it back again at v0.12.0.

I can't found any document for it so maybe just an accident?

frederikhors commented 4 weeks ago

Maybe docs is needed for things like this too: https://users.rust-lang.org/t/from-hyper-legacy-client-to-reqwest-0-12-how-to-handle-stream-upload-put-and-stream-download-get-from-s3/112520/2.

jofas commented 4 weeks ago

@frederikhors your other URLO-topic is also somewhat related:

I tried reqwest::Body::wrap_stream with both axum::Body::into_data_stream and http_body_util::BodyStream, both failed because axum::body::Body is not Sync.

2088 seems to be at least partially motivated by the need to use axum's BodyDataStream with reqwest's Body type:

By using SyncWrapper we can avoid requiring Sync for the stream passed to Body::wrap_stream. This makes it easier to use streams like axum's BodyDataStream.

I think it was indeed just an accident that the Sync bound was reintroduced in #2059, at least that is how I interpret https://github.com/seanmonstar/reqwest/pull/2229#issuecomment-2029663514