I am now using the https module to send some https POST requests.
A new requirement came up: the server's SSL support may be switched on or off. So I must use either https or http accordingly.
How do I send http requests using the https module? (the opposite would be helpful too)
According to the docs for function https.request(options[, callback]),
options.protocolDefaults tohttps:
I tried changing this to http:, for example,
var options = {
protocol: "http:",
...
};
https.request(options, function (res) { ... });
but got error
Error: Protocol "http:" not supported. Expected "https:"