Skip to content
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

Closed
wants to merge 0 commits into from
Closed

Conversation

JustFrederik
Copy link
Contributor

@JustFrederik JustFrederik commented Sep 17, 2023

Its basically just ureq_multipart, but without the converion to ureqs Request so it will work with wasm.

use ehttp::multipart::MultipartBuilder;
let builder = MultipartBuilder::new()
            .add_file("test","/home/feiy/Desktop/1.txt").unwrap()
            .add_text("name","value");
let request = ehttp::Request:multipart(url, builder);

Copy link
Owner

@emilk emilk left a 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

ehttp/src/types.rs Outdated Show resolved Hide resolved
@JustFrederik
Copy link
Contributor Author

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

@JustFrederik
Copy link
Contributor Author

Should I add the method setter?

ehttp/Cargo.toml Outdated Show resolved Hide resolved
ehttp/Cargo.toml Outdated Show resolved Hide resolved
ehttp/src/types.rs Outdated Show resolved Hide resolved
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
@tmtbe
Copy link

tmtbe commented Dec 7, 2023

This pr doesn't seem to have changed in a long time.

@JustFrederik JustFrederik requested a review from emilk December 13, 2023 07:14
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
ehttp/src/multipart.rs Outdated Show resolved Hide resolved
@JustFrederik JustFrederik requested a review from emilk December 26, 2023 13:59
Comment on lines 119 to 129
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
)
}
Copy link
Owner

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

name: &str,
filename: Option<&str>,
content_type: Option<Mime>,
) -> io::Result<()> {
Copy link
Owner

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

/// * 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>)> {
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants