Node.js- HTTPS - Modul

❮ Eingebaute Module


Beispiel

Erstellen Sie einen https-Server, der auf Port 8080 Ihres Computers lauscht.

Wenn auf Port 8080 zugegriffen wird, schreiben Sie "Hello World!" zurück als Antwort:

var https = require('https');

https.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write('Hello World!');
  res.end();
}).listen(8080);

Definition und Verwendung

Das HTTPS-Modul bietet eine Möglichkeit, Node.js dazu zu bringen, Daten über das HTTP TLS/SSL-Protokoll zu übertragen, das das sichere HTTP-Protokoll ist.


Syntax

Die Syntax zum Einbinden des HTTPS-Moduls in Ihre Anwendung:

var https = require('https');

HTTPS-Eigenschaften und -Methoden

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

❮ Eingebaute Module