Open sgrove opened 7 years ago
I'm tempted to suggest it belongs in a separate library that can be instantiated in a separate unikernel to the webserver in any deployment; but I don't know if that would fit with what the use you have in mind :)
(That may make more sense for SOCKS5 than HTTP proxy I guess. https://github.com/cfcs/ocaml-socks may also be relevant.)
My use case is simply that when I make an http request, I need it to go through a proxy (hosted on another machine, of course). For example, with the most popular Clojure http client's proxy support, it's simply a matter of passing in some extra named arguments (or the equivalent thereof):
;; No proxy, request will be directly between this machine and foo.com
(client/get "http://foo.com")
;; Request will go through HTTP proxy myproxyhost.com:8118
(client/get "http://foo.com" {:proxy-host "myproxyhost.com" :proxy-port 8118})
;; Request will go through SOCKS proxy
(client/get "http://foo.com"
{:connection-manager
(conn-mgr/make-socks-proxied-conn-manager "mysocksproxyhost.com" 8081)})
Connections can also be stored and reused elsewhere, which can be useful for a number of different things.
What would the equivalent look like with Cohttp?
I'm also interested if you have some informations about that.
With Go's example:
proxyUrl, err := url.Parse("http://proxyIp:proxyPort")
myClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
It's been nearly 2 years since @sgrove post this issue firstly, but there's still no answer for this common issue. I think this is one of the reason that keep people far away from OCaml.
I need to use SOCKS5 and HTTP proxies with Cohttp. I'm not sure if support belongs in the library proper, or another library with a bit of glue to work with Cohttp.
Is this possible currently?