Open YenForYang opened 3 years ago
I hadn't noticed the text you mentioned. Yes, I'd be happy for the crate to explicitly support multipart/mixed
then. The caveats you mentioned could certainly be fixed. (To support bodies without Content-Length
, maybe it could make a memchr::memmem::Finder
the first time it sees part headers without a Content-Length
.)
Are you interested in putting together a PR?
One other caveat I didn't mention is that it buffers each part fully in memory. If that's not what you want, we'd need an API change to have each part's body be a Stream
itself. And we'd need to decide what happens if you try to get the next part before fully consuming previous part's body streams: does getting the next part implicitly wait for you to fully consume or drop the previous part's body stream, is it an error, or does it force it to be buffered in RAM.
I found the Content-Length
thing useful for my camera so I made a pull request here: https://github.com/scottlamb/multipart-stream-rs/pull/3
I'm actually not sure if this crate supports
multipart/mixed
or not, since the README mentions it as part of the introduction. Nonetheless I think this crate would find much more use if it supportedmultipart/mixed
(explicitly) since it's quite similar tomultipart/x-mixed-replace
. In fact, the WHATWG page mentioned in the README even states:I'm looking for a crate that can create/parse requests/responses like these (batch requests to Google APIs, like Drive v3), while working with
reqwest
/hyper
.Request example:
Response example:
Pretty much all the requirements your README mentions are met, except for:
The
Content-Length
requirement is also limiting, but it happens to work perfectly for use cases surrounding batch Google Drive/Gmail requests. The APIs seem to support sendingmultipart/mixed
requests with/withoutContent-Length
, and always returns parts that includeContent-Length
(as seen above).There don't appear to be any libraries around
multipart/*mixed*
in Rust (all the ones that could work seem to predateasync
support), so I thought yours was promising since it has both async and hyper support.