feat(multipart): add Form::set_boundary for custom boundaries#1094
feat(multipart): add Form::set_boundary for custom boundaries#10940x676e67 merged 5 commits into0x676e67:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the multipart form functionality by providing a mechanism for users to specify custom boundary strings. This capability is vital for use cases such as browser emulation, where precise control over the multipart boundary is necessary to mimic specific client behaviors. The implementation includes clear documentation regarding the potential risks of using custom boundaries and is thoroughly tested to ensure its reliability. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds the ability to set a custom boundary for multipart forms, which is a useful feature for browser emulation. The implementation is straightforward and follows the pattern of similar APIs in other libraries. The addition of both unit and integration tests is great. I've found one issue in the new integration test related to how a multi-line string is defined, which would likely cause the test to fail. I've left a suggestion to fix it. This seems to be a pattern copied from other tests, so it might be worth fixing it in other places as well.
|
I prefer the "with_boundary" initialization method over "set_boundary". pub fn with_boundary(boundary: impl Into<String>) -> Form {
let mut inner = FormParts::new();
inner.boundary = boundary;
Form { inner }
} |
Done. Let me know if there's something else to change. First time contributing here, so not sure about the conventions |
Adds
Form::set_boundary(&mut self, boundary: impl Into<String>)so users can specify their own multipart boundary string (e.g.------WebKitFormBoundary...for browser emulation). This is useful for matching browser fingerprints during emulation, since the defaultgen_boundary()output doesn't resemble any real browser.API and doc comment follow reqwest's approach in seanmonstar/reqwest#2814. Includes unit and integration tests.
Closes #1030