nevermind
nevermind

Reputation: 266

How to send node.js http request via proxy (using require('http').request method)

Probably related to How can I use an http proxy with node.js http.Client?

I've read this post, and tried it here. https://gist.github.com/lessmind/5704519

the request function sends a request to specify url, print the request options and page body, when it got a proxy param, it'll parse it and set into the request options as this post said.

But when I tried it on http://showip.net/, the returned ip are the same with proxy or not.

Did I make anything wrong? Or any other way to send a request via proxy?

Upvotes: 4

Views: 9449

Answers (1)

nevermind
nevermind

Reputation: 266

According to http://nodejs.org/api/http.html#http_http_request_options_callback

hostname: To support url.parse() hostname is preferred over host

Should add this line when overwriting proxy informations.

options.hostname = proxy.hostname;

Upvotes: 3

Related Questions