http icon indicating copy to clipboard operation
http copied to clipboard

feat: support conversions from `url::Url`

Open davidbarsky opened this issue 4 years ago • 4 comments

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 from url::Url allows for building complex queries using url::Url's builder methods, but then converting to http::Uri at request construction time.
  • Since all of http's builders implement accept a TryFrom<T> (in http::request::Builder's case, a Uri: TryFrom<T>), this feature allows for passing a url::Url into a request builder.

davidbarsky avatar Dec 19 '19 21:12 davidbarsky

(cc: @seanmonstar.)

davidbarsky avatar Dec 19 '19 21:12 davidbarsky

Relevant discussion about why this hasn't been implemented in the past: https://github.com/hyperium/http/issues/73

seanmonstar avatar Dec 19 '19 22:12 seanmonstar

@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.

davidbarsky avatar Dec 19 '19 22:12 davidbarsky

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.)

davidbarsky avatar Feb 13 '20 19:02 davidbarsky