node-ovh icon indicating copy to clipboard operation
node-ovh copied to clipboard

HTTPS proxy support

Open debrouxl opened this issue 9 years ago • 3 comments

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 :)

debrouxl avatar Jun 08 '15 13:06 debrouxl

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.

jbblanchet avatar Aug 06 '15 19:08 jbblanchet

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.

debrouxl avatar Aug 07 '15 05:08 debrouxl

Stil no support for proxy settings ?

loganmzz avatar Mar 20 '20 15:03 loganmzz