Comments (4)
How about an adapter that implements Read
? With multipart::client::lazy::Multipart
you can build your multipart body then call .prepare()
which returns a type that implements Read
, that you should then be able to return as your response body, or copy out to your response, depending on what HTTP framework you're using.
from multipart.
That might work, but it still sounds complicated. Could you explain why tying the construction of the body of the HTML request is so strongly tied to a Request
or a Client
? Is that because of streaming?
from multipart.
It's primarily to ensure that the right header is supplied with the request. The multipart boundary that separates each field in the body has to be supplied in the Content-Type
header of the request, and each HTTP framework does headers slightly differently. This approach has better ergonomics for the common case where you're constructing the multipart body in the process of submitting a request. Otherwise it would be easy to forget to supply the boundary with the request and would cause difficult to debug errors on the server side.
I've done a different approach in src\local_test.rs
where I have a mock implementation of HttpRequest
that simply writes the request to a Vec
and stores the boundary. I could extract this to the library proper but I didn't see the utility in it outside of testing.
from multipart.
Thanks for explaining everything!
I took a different approach for my problem now, so this is not required for me anymore and I think my use case was rather esoteric. I would suggest you do not pull the code out until the next one with a similar problem comes around. Closing the issue for now.
from multipart.
Related Issues (20)
- Rocket example no longer builds HOT 3
- Gotham example HOT 1
- Multipart.foreach_entry() panics on unseen keys, is it expected? HOT 9
- Cutting a release? HOT 8
- Saving a temp file with file extension HOT 2
- Calling `form.prepare()?.boundary()` twice panics HOT 2
- Unable to write multipart to file in rocket HOT 1
- How to save the file to server?
- how to support actix? HOT 1
- is there a way to use this with cgi? HOT 1
- Maintenance status/dependency bump request HOT 2
- bad issues, del this.
- Got MissingContentDisposition Error when parsing the response body of Multipart ranges
- Upgrade to rand 0.8 HOT 1
- "\r\n" straddling the buffer end is erroneously sent as part of the part's contents.
- hyper::server::Request
- Default features do not make sense HOT 2
- Can you help me figure how to make this work with Rust 2018? HOT 4
- twoway dependency is dead HOT 6
- the following packages contain code that will be rejected by a future version of Rust: multipart v0.18.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multipart.