Hyper 0.13 server side parses multi-part form data from

There are several crates to parse HTTP multi-part post form but none of them can work with hyper 0.13 because breaking changes in hyper

abonander/multipart seems can be adapted.
Generally I need implement its multipart::server::HttpRequest trait for hyper::Request (which is actually http::Request )

I tried to do that but sooner receives an error.

107 | impl multipart::server::HttpRequest for hyper::Request<hyper::body::Body> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------
    | |                                       |
    | |                                       `http::request::Request` is not defined in the current crate
    | impl doesn't use only types from inside the current crate
    |
    = note: define and implement a trait or new type instead

Please is there some other way to parse multi-part in hyper 0.13 server ?

Lookup "Rust orphan rules" for an answer to what goes wrong here. You can work around it by wrapping the type in your crate, or modifying the crate that exposes the type (and file a PR) if that's appropriate.

I don't use hyper atm, so I don't have an answer to what the best solution for your overall problem is, sorry.

1 Like

You would have to create a newtype wrapper for hyper::Request. The book has a chapter on this technique.

struct MyRequest(hyper::Request<hyper::body::Body>);

impl multipart::server::HttpRequest for MyRequest {
    ...
}
1 Like