owainlewis / digital-ocean

Idiomatic Clojure client for Digital Ocean that makes it easy to boot virtual servers from your REPL
37 stars 13 forks source link

Library does not support http proxy #13

Open behrica opened 10 years ago

behrica commented 10 years ago

I noticed that it does not work with a http proxy.

I investigated a bit, a it seems that httpkit does not support a proxy at all:

https://github.com/http-kit/http-kit/issues/75

and won´t do so in the near future.

This is for me a killer argument... All corporate environments use http proxies these days, so does mine. So any web services / REST client API should support it.

behrica commented 10 years ago

I found a potential way to solve this. It requires:

  1. Use clj-http instead of http-kit, as http-kit does not seem to support proxies soon
  2. The current latest released version of "clj-http" (1.0.0) does not support it neither, but there is a commit on master branch, which does support it. I tried this version for me and it works
  3. The "request" method need to be changed to use clj-http, but this is rather simple:
{:keys [status headers body error] :as resp} (http/get url {:proxy-host HOST :proxy-port PORT :proxy-user PROXY-USER :proxy-pass PROXY-PASS})]

We needed to decide, how to pass in the proxy credentials into all methods.

I am not sure, if this would handle ALL proxy scenarios, but the large majority. In any case more complex proxy configurations are not present in clj-http neither by now (but they are present n the appache http client components it is based on). And this would match with the proxy configuration options the JDK provides (and therefore all Clojure network methods based on JDK methods)