http
http copied to clipboard
feat: support conversions from `url::Url`
Motivation
- A few AWS services (like SQS, IAM, EC2) use
application/x-www-form-urlencoded
-based RPC calls. While this encoding is typically handled by the SDKs, this code needs to exist somewhere. - An off-by-default feature flag enabling a
TryFrom
conversion fromurl::Url
allows for building complex queries usingurl::Url
's builder methods, but then converting tohttp::Uri
at request construction time. - Since all of
http
's builders implement accept aTryFrom<T>
(inhttp::request::Builder
's case, aUri: TryFrom<T>
), this feature allows for passing aurl::Url
into a request builder.
(cc: @seanmonstar.)
Relevant discussion about why this hasn't been implemented in the past: https://github.com/hyperium/http/issues/73
@seanmonstar Thanks for the background context. There are a few circumstances—namely, the AWS use-case—where I am constructing full URLs, not just URI fragments that compose into a target of an HTTP request. I think this PR implements the relatively conservative conversions as outlined in Carl's comment: https://github.com/hyperium/http/issues/73#issuecomment-319422772.
Not sure if any decision have been made on this PR but I think something along the lines of https://github.com/hyperium/http/pull/276 would address some of the goals of this PR. I'd be happy to revive #276.
(cc: @carllerche.)