javascript - Create HTTPS client in NodeJS -
i've been having heck of time figuring out how use node.js (v0.3.8) securely connect http server. have following code:
var http = require("http"); var client = http.createclient(443, host, /* secure= */ true); var request = client.request("get", relativeurl, { host: host });
when run it, get:
node.js:116 throw e; // process.nexttick error, or 'error' event on first tick ^ error: parse error @ client.ondata [as ondata] (http.js:1287:27) @ client._onreadable (net.js:648:27) @ iowatcher.onreadable [as callback] (net.js:156:10)
i've been googling answers past half hour, , have read documentation @ http://nodejs.org/ . missing?
it turns out using old version of node documentation, didn't include reference https
module. referring current docs, found http://nodejs.org/docs/latest/api/https.html#https_https_get_options_callback, provides example:
https.get({ host: 'encrypted.google.com', path: '/' }, function (res) { … });
Comments
Post a Comment