-
Notifications
You must be signed in to change notification settings - Fork 51
Add with_form method for URL-encoded form data
#470
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
base: master
Are you sure you want to change the base?
Conversation
Add support for sending application/x-www-form-urlencoded form data in HTTP requests via a new `with_form()` method on `Request`. - Add `serde_urlencoded` dependency for form serialization - Add `SerdeUrlencodeError` variant to handle encoding failures - Add unit tests for form encoding behavior - Add integration tests for form submission
f341a66 to
a253ca1
Compare
Add instead a minimal equivalent that uses serde to serialize any struct with url encoding
| } | ||
|
|
||
| /// Percent-encode a string for use in URL form data. | ||
| fn percent_encode(s: &str) -> String { |
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.
Not the biggest fan of adding all this serialization boilerplate here. At the very least we should DRY this up after #467 lands, as we have at least all the the percent encoding stuff, etc there.
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.
The alternative would be to receive something that can be converted into Vec<(&str, &str)>, and in that case, it would be useful enough, but I think, since this would be optional, using some serde magic is acceptable, but I lack context to make that judgment call.
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.
Offering only the serde-based option kinda sucks (now you have to use serde just to percent-encode a few fields? bleh) but if y'all have a desire for a serde-based option I don't see a reason that we can't offer it as well.
Indeed, though, we should figure out how to sequence this with #467 since there's overlap.
Add support for sending application/x-www-form-urlencoded form data in HTTP requests via a new
with_form()method onRequest.serde_urlencodeddependency for form serializationSerdeUrlencodeErrorvariant to handle encoding failures