ovh / node-ovh

Node.js wrapper for the OVH APIs
http://ovh.github.io/node-ovh
Other
129 stars 27 forks source link

HTTPS proxy support #3

Open debrouxl opened 9 years ago

debrouxl commented 9 years ago

For the poor guys and girls among us who have to deal with HTTPS proxies, a way to tell the ovh module that the .request method should attempt to access the OVH HTTPS API through a proxy would be great :)

AFAICT, the proper way to have HTTP/HTTPS requests go through a proxy is to pass an instance of https.Agent ( https://nodejs.org/api/https.html#https_class_https_agent ) as 'agent' property of the 'options' argument to https.request(). One of the ways to create such agents is https://www.npmjs.com/package/tunnel-agent , which has the same API as https://www.npmjs.com/package/tunnel .

I could attempt to contribute a patch by myself, but I'd rather discuss the direction with the maintainer up front. I can see at least three reasonable ways to pass the agent to an instance of the ovh module for .request() to use (.loadSchemasRequest() already takes options passed directly to https.get()): 1) at initialization time, require('ovh')({ ...}) - less flexible IMO; 2) at any point, through a setter which would apply to future invocations of the .request() method; 3) at request time, through a new argument to e.g. ovh.request(); and at least a dirty way: pass the agent through a specially-named property of the 'params' argument to ovh.request(), which is probably what I'll attempt to use for my own purposes, as a temporary measure. Your preference may not match mine, and might not even be listed here :)

jbblanchet commented 9 years ago

Hi. Sorry for the delay.

I'm willing to consider a pull request for such a change. I think this custom agent should be settable both through the constructor or a setCustomAgent method (which could accept undefined or null to remove the agent). Let me know if you want to discuss this further.

Thanks.

debrouxl commented 9 years ago

Hi,

Alright, I'll integrate such changes into the code base in a couple weeks (I'm currently on holiday), test it and send a pull request.

loganmzz commented 4 years ago

Stil no support for proxy settings ?