Node.jsHTTPSモジュール_

❮内蔵モジュール


コンピューターのポート8080でリッスンするhttpsサーバーを作成します。

ポート8080にアクセスしたら、「HelloWorld!」と記述します。応答として戻る:

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モジュールは、安全なHTTPプロトコルであるHTTP TLS / SSLプロトコルを介してNode.jsにデータを転送させる方法を提供します。


構文

アプリケーションに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

❮内蔵モジュール