keenlabs / KeenClient-Java

Official Java client for the Keen IO API. Build analytics features directly into your Java apps.
https://keen.io/docs
MIT License
74 stars 43 forks source link

Add Support For Proxy Servers #12

Closed ryber closed 9 years ago

ryber commented 10 years ago

Hi, I'd like to have direct access to configuring proxy servers for the client to call through without environmental variables.

I'm willing to issue a pull request . I'd like to just run over the design I'm thinking of. Please point me in a different direction if you would like something else.

I was going to add a method: KeenConfig.setProxy(url). Internally this would create a java.net.Proxy instance for use with the HttpURLConnection in KeenHttpRequestRunnable.

I am more reluctant about the username and password. The only way I know of to set the authentication with HttpURLConnection is to set the default authenticator. This is a global variable. So I would rather not do that from code unless you moved to a library that supported it like (I think) Apache HttpClient. I personally don't need the authentication end, but I wanted to include it here for your thoughts.

dkador commented 10 years ago

I think your suggestion would work well. Would love to see a PR in this fashion.

I'm pretty against adding more external dependencies if we can avoid it (especially on things like HttpClient where you can easily get yourself into versioning mismatch hell). It is pretty annoying that auth is global across the JDK. I think for now let's leave it alone. We could add a section to the README that says if you want to use a proxy with auth, you need to set the default Authenticator and also call KeenConfig.setProxy(). That'd be nice.

Geeber commented 9 years ago

This is supported as of 2.0.3 - see https://github.com/keenlabs/KeenClient-Java#using-an-http-proxy.