kriskowal / q-io

Interfaces for IO using Q promises in JavaScript on Node

Home Page:http://documentup.com/kriskowal/q-io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proxy requests

thabti opened this issue · comments

commented

Hi,

So our internal cloud allows external calls via a proxy server, how can I tell q-io to use environment variable of the proxy server host and port ?

Because Q-IO is just using http.request under the hood, you should be able to follow this StoackOverflow answer:

http.request({
    hostname: '127.0.0.1:8888', // your proxy
    path: 'http://example.com/' // the URL you actually want to get
}).then(function (response) {
    console.log(response);
});

I haven't actually tried this, so let me know how it goes.

hostname + ":" + port = host. You can use either hostname and port, or just host. To write a full-fledged HTTP proxy, you would parse these out of the received request.path and forward the domain relative path to the proxied server, but that may or may not be your intent.