وحدة Node.js HTTPS

❮ وحدات مدمجة


مثال

قم بإنشاء خادم https يستمع إلى المنفذ 8080 بجهاز الكمبيوتر الخاص بك.

عند الوصول إلى المنفذ 8080 ، اكتب "Hello World!" العودة كرد:

var https = require('https');

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

التعريف والاستخدام

توفر وحدة HTTPS طريقة لجعل Node.js ينقل البيانات عبر بروتوكول HTTP TLS / SSL ، وهو بروتوكول HTTP الآمن.


بناء الجملة

بناء الجملة لتضمين وحدة HTTPS في تطبيقك:

var https = require('https');

خصائص وطرق HTTPS

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

❮ وحدات مدمجة