mirage / ocaml-cohttp

An OCaml library for HTTP clients and servers using Lwt or Async
Other
712 stars 174 forks source link

Make Uri optional when constructing requests #390

Open rgrinberg opened 9 years ago

rgrinberg commented 9 years ago

Currently cohttp is hardcoded to use Uri when both creating requests and reading responses. Here are some disadvantages of that:

The biggest problem here is obviously the first one since there's absolutely no work arounds but the others are important too. This change is also congruent with our goal of keeping cohttp low level and flexible.

The amount of breakage this would cause should range from minimal to moderate for our users:

@avsm @dsheets @SGrondin thoughts?

SGrondin commented 9 years ago

Uri of Uri.t | Ip of Ip_addr.t * int | Pipe of ic * oc as suggested by @rgrinberg on Gitter is exactly what I need :+1: :+1: :+1:

I plan on providing both an Uri.t and an Ip_addr.t * int tuple. That way I can have strict control over address resolution, manipulation and caching while retaining the high level Uri abstractions. Best of both worlds.

Personally, this is my single most desired feature for cohttp.

rgrinberg commented 9 years ago

The above reference a possible type for targeting a cohttp client. Uri u would give us the current behavior.

edwintorok commented 8 years ago

Access to the raw request Uri would be useful in some situations (e.g. S3 sign requests using an HMAC, and you need to verify the signature on the original Uri, not a normalized variant of it). Ocsigen provides this, would be nice if Cohttp did too. The {Request,Response}.uri solution would work for me if the original Uri is also available as a string.