Node.js HTTPS - module
Voorbeeld
Skep 'n https-bediener wat op poort 8080 van jou rekenaar luister.
Wanneer toegang tot poort 8080 verkry word, skryf "Hallo Wêreld!" terug as 'n antwoord:
var https = require('https');
https.createServer(function (req, res)
{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World!');
res.end();
}).listen(8080);
Definisie en gebruik
Die HTTPS-module bied 'n manier om Node.js-data oor HTTP TLS/SSL-protokol te laat oordra, wat die veilige HTTP-protokol is.
Sintaksis
Die sintaksis om die HTTPS-module in jou toepassing in te sluit:
var https = require('https');
HTTPS-eienskappe en -metodes
Method | Description |
---|---|
createServer() | Creates an HTTPS server |
get() | Sets the method to GET, and returns an object containing the user's request |
globalAgent | Returns the HTTPS Agent |
request | Makes a request to a secure web server |