I have been trying to send GET requests to a web server through public proxy servers. But not sure how to pass GET path to the proxy.
I tried to pass path parameter in options as well as in Host header as well. It's not working anyhow. Here's what I've tried so far.
var proxy = { ip: '121.12.1.1', port: 3128 };
var options = {
uri: 'http://' + proxy.ip + ':' + proxy.port,
method: 'GET',
path: '/json',
headers: {
'Host': 'http://wtfismyip.com/json'
}
};
request(options, function (error, response, body) {
if (!error && response && (response.statusCode == 200 || response.statusCode == 302 ) ) {
console.log("success proxy response: ", response && response.statusCode, body);
}
else {
console.log("error in proxy response: ", err, response && response.statusCode);
}
})
But its only calling http://wtfismyip.com/. So, how do I call http://wtfismyip.com/json through the proxy server?