}).listen(8000);
-## https.request
+## https.request(options, callback)
Makes a request to a secure web server.
+Similar options to `http.request()`.
Example:
console.error(e);
});
+## https.get(options, callback)
+Like `http.get()` but for HTTPS.
+
+Example:
+
+ var https = require('https');
+
+ https.get({ host: 'encrypted.google.com', path: '/' }, function(res) {
+ console.log("statusCode: ", res.statusCode);
+ console.log("headers: ", res.headers);
+
+ res.on('data', function(d) {
+ process.stdout.write(d);
+ });
+
+ }).on('error', function(e) {
+ console.error(e);
+ });
function getAgent(options) {
+ if (!options.port) options.port = 443;
+
var id = options.host + ':' + options.port;
var agent = agents[id];
var agent = getAgent(options);
return http._requestFromAgent(agent, options, cb);
};
+
+
+exports.get = function(options, cb) {
+ options.method = 'GET';
+ var req = exports.request(options, cb);
+ req.end();
+ return req;
+};