-
Notifications
You must be signed in to change notification settings - Fork 176
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
cohttp-eio: add Client.make_generic and HTTPS support #1002
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,16 +9,20 @@ include | |||||
and type body = Body.t | ||||||
|
||||||
val make : | ||||||
https:(Uri.t -> [`Generic] Eio.Net.stream_socket_ty r -> _ Eio.Flow.two_way) option -> | ||||||
_ Eio.Net.t -> t | ||||||
(** [make ~https net] is a convenience wrapper around {!make_generic} that | ||||||
uses [net] to make connections. | ||||||
https: | ||||||
(Uri.t -> [ `Generic ] Eio.Net.stream_socket_ty r -> _ Eio.Flow.two_way) | ||||||
option -> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since it is no longer optional, why not dropping the option from the signature? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https support is optional (you don't have to use it); see #984 (comment):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the plan is to have a separate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree. I was recalling what we had discussed incorrectly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this signature ok as is, or do we need to change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I would prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave it as is. We can make it optional in due course once there is the tls package if we can think of a better way to deal with it |
||||||
_ Eio.Net.t -> | ||||||
t | ||||||
(** [make ~https net] is a convenience wrapper around {!make_generic} that uses | ||||||
[net] to make connections. | ||||||
- URIs of the form "http://host:port/..." connect to the given TCP host and port. | ||||||
- URIs of the form "https://host:port/..." connect to the given TCP host and port, | ||||||
and are then wrapped by [https] (or rejected if that is [None]). | ||||||
- URIs of the form "httpunix://unix-path/http-path" connect to the given Unix path. | ||||||
*) | ||||||
- URIs of the form "http://host:port/..." connect to the given TCP host and | ||||||
port. | ||||||
- URIs of the form "https://host:port/..." connect to the given TCP host and | ||||||
port, and are then wrapped by [https] (or rejected if that is [None]). | ||||||
- URIs of the form "httpunix://unix-path/http-path" connect to the given | ||||||
Unix path. *) | ||||||
|
||||||
val make_generic : (sw:Switch.t -> Uri.t -> _ Eio.Net.stream_socket) -> t | ||||||
(** [make_generic connect] is an HTTP client that uses [connect] to get the | ||||||
|
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.
I am a bit sad with the amount of boilerplate we have to come up to do a simple
https
call. Could we somehow ship a default authenticator as well? The current API doesn't look very simple to use.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.
We can't ship a default authenticator without adding extra dependencies to cohttp-eio. The plan is to have another package for that later (either cohttp-eio-tls, or maybe something conduit-like); this PR is just making that possible.
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.
I think we could merge this and release it as beta, so that people can test it out in the meantime and inform possible api refinements. But I agree with @samoht, and I think it would be nice to have
cohttp-eio-tls
before we release the new stable 6.0.0There 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.
That sounds like a good plan. I'm already using that PR in a project of mine and it's working great 👍 Thanks for this!