-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I added a multipart feature #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! Can you please add some helpful docstrings to the key things? 🙏
Especially to Request::multipart
and to MultipartBuilder
I added an example to request::multipart. The multipart builder already had some documentation, but is also used in the example |
Should I add the method setter? |
This pr doesn't seem to have changed in a long time. |
ehttp/src/multipart.rs
Outdated
fn write_boundary(&mut self) -> io::Result<()> { | ||
if self.data_written { | ||
self.inner.write_all(b"\r\n")?; | ||
} | ||
|
||
write!( | ||
self.inner, | ||
"-----------------------------{}\r\n", | ||
self.boundary | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing to a Vec<u8>
can never fail, so no need to return a Result
here.
Instead you can either unwrap()
the write!
s in here, or use self.inner.extend_from_slice(b"\r\n")
etc
ehttp/src/multipart.rs
Outdated
name: &str, | ||
filename: Option<&str>, | ||
content_type: Option<Mime>, | ||
) -> io::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - there should be no need for Result
ehttp/src/multipart.rs
Outdated
/// * content_type http header content type | ||
/// * post_data ureq.req.send_send_bytes(&post_data) | ||
/// | ||
pub fn finish(mut self) -> io::Result<(String, Vec<u8>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no need for Result
Its basically just ureq_multipart, but without the converion to ureqs Request so it will work with wasm.