Comments (5)
The first idea was to use
request.headers_mut().set(ContentLength(meta_json.len() as u64 + size_srpm as u64));
but that results in
failed to write whole buffer
when spawning the multipart struct
from multipart.
The following produces the same error:
let mut request = Request::with_connector(Method::Post, url, &connector)
.chain_err(||"Failed to create POST request")?;
request.headers_mut().set(
ContentType(
Mime(
TopLevel::Multipart, SubLevel::Ext("form-data".into()),
vec![(Attr::Ext("boundary".into()), Value::Ext(boundary.into()))]
)
)
);
request.headers_mut().set(ContentLength(meta_json.len() as u64 + size_srpm as u64));
let mut multipart = Multipart::from_request(request).chain_err(||"Failed to create multipart request")?;
from multipart.
Total length is 1260944
[ bytes ] which is not too much to allocate ..
from multipart.
The ContentLength
value has to be the whole size of the body, including multipart boundaries and field headers.
If you use Multipart::from_request_sized()
it will set the ContentLength
header correctly, though the implementation is incredibly naive; it just writes the whole request to an in-memory buffer to get the length that way and then writes it out to the stream in one fell swoop.
from multipart.
Understood, I ended up doing exactly that.
I think there is no other way around that since the headers are only to be written with Request where body is only to be written with Request given hyper's implementation.
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.