node-wot
node-wot copied to clipboard
[binding-http] Improve proxy support
The current proxy support in binding-http
is rudimentary and does not support some often used scenarios, e.g. https
requests over a http
proxy as often used in corporate scenarios.
In this case, the client first has to send an unencrypted CONNECT
request to the proxy and the use the established connection to setup the TLS encryption and make the https
request to the target host.
Such use cases are not directly supported by the http
and https
packages of nodejs and are therefore also currently not supported by binding-http
. See also the (quite old, but apparently still valid) discussion in https://github.com/nodejs/node-v0.x-archive/issues/2474, which was closed, because the issue can be resolved in userland, e.g. as shown in the reply https://github.com/nodejs/node-v0.x-archive/issues/2474#issuecomment-3481078.
Instead of implementing something similar I propose to use the request
library. See https://github.com/request/request and https://www.npmjs.com/package/request, which implements all the necessary mechanisms and much more.
Currently, we changed binding-http
implementation to use node-fetch which in theory has better support for proxies. Currently, we don't allow configuration of the proxy like here, but we can do it in the future if somebody else has the same use case.