From 811ccdf06a70ff9430de78896f979036eee957dd Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Mon, 3 Apr 2017 02:55:01 +0300 Subject: [PATCH] doc: modernize and fix code examples in https.md * Replace `var` by `const`. * Comment out ellipses. * Update code example (provide relevant file path, add missing option). PR-URL: https://github.com/nodejs/node/pull/12171 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/https.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/api/https.md b/doc/api/https.md index 355fd7b133a76d..12ebef2bf8ce4b 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -69,7 +69,8 @@ const https = require('https'); const fs = require('fs'); const options = { - pfx: fs.readFileSync('server.pfx') + pfx: fs.readFileSync('test/fixtures/test_cert.pfx'), + passphrase: 'sample' }; https.createServer(options, (req, res) => { @@ -143,14 +144,14 @@ Example: ```js const https = require('https'); -var options = { +const options = { hostname: 'encrypted.google.com', port: 443, path: '/', method: 'GET' }; -var req = https.request(options, (res) => { +const req = https.request(options, (res) => { console.log('statusCode:', res.statusCode); console.log('headers:', res.headers); @@ -218,7 +219,7 @@ In order to specify these options, use a custom [`Agent`][]. Example: ```js -var options = { +const options = { hostname: 'encrypted.google.com', port: 443, path: '/', @@ -228,8 +229,8 @@ var options = { }; options.agent = new https.Agent(options); -var req = https.request(options, (res) => { - ... +const req = https.request(options, (res) => { + // ... }); ``` @@ -238,7 +239,7 @@ Alternatively, opt out of connection pooling by not using an `Agent`. Example: ```js -var options = { +const options = { hostname: 'encrypted.google.com', port: 443, path: '/', @@ -248,8 +249,8 @@ var options = { agent: false }; -var req = https.request(options, (res) => { - ... +const req = https.request(options, (res) => { + // ... }); ```