maoertel / diqwest

Crate to extend `reqwest` to be able to send with digest auth flow.
https://docs.rs/diqwest
MIT License
18 stars 3 forks source link

Error: Diqwest(RequestBuilderNotCloneable) Request body must not be a stream #15

Closed tomkcey closed 7 months ago

tomkcey commented 7 months ago

Hi,

First, thanks for this crate. It's useful.

I'm encountering sort of an edge case where I'm consuming an API endpoint that requires digest auth and a multipart/form-data body.

Upon sending the request with send_with_digest_auth(), I get the error as written in the title.

I've been having some difficulty finding the same use case and solutions following some google search. Would you have a suggestion?

I'm passing a Vec<u8> to reqwest::multipart::Form, and that buffer is acquired from std::fs::read().

tomkcey commented 7 months ago

Will close this issue because I have found a solution. I simply built the multipart body manually, in memory. This way it's a cloneable body and doesn't trigger the "You can't use a stream in the body", or somesuch.

It's not very elegant and there seems to be crates out there that could do the heavy lifting, so for anyone stumbling upon this make sure to take a look.

Bit of a bummer though. For my use case the transfered files are super small but for larger file sizes finding another solution is probably preferable.