Skip to content

Commit 811ccdf

Browse files
vsemozhetbytMylesBorins
authored andcommitted
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: #12171 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c0d9b1c commit 811ccdf

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎doc/api/https.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ const https = require('https');
6969
constfs=require('fs');
7070

7171
constoptions= {
72-
pfx:fs.readFileSync('server.pfx')
72+
pfx:fs.readFileSync('test/fixtures/test_cert.pfx'),
73+
passphrase:'sample'
7374
};
7475

7576
https.createServer(options, (req, res) => {
@@ -143,14 +144,14 @@ Example:
143144
```js
144145
consthttps=require('https');
145146

146-
var options = {
147+
constoptions= {
147148
hostname:'encrypted.google.com',
148149
port:443,
149150
path:'/',
150151
method:'GET'
151152
};
152153

153-
var req =https.request(options, (res) => {
154+
constreq=https.request(options, (res) => {
154155
console.log('statusCode:', res.statusCode);
155156
console.log('headers:', res.headers);
156157

@@ -218,7 +219,7 @@ In order to specify these options, use a custom [`Agent`][].
218219
Example:
219220

220221
```js
221-
var options = {
222+
constoptions= {
222223
hostname:'encrypted.google.com',
223224
port:443,
224225
path:'/',
@@ -228,8 +229,8 @@ var options = {
228229
};
229230
options.agent=newhttps.Agent(options);
230231

231-
var req =https.request(options, (res) => {
232-
...
232+
constreq=https.request(options, (res) => {
233+
//...
233234
});
234235
```
235236

@@ -238,7 +239,7 @@ Alternatively, opt out of connection pooling by not using an `Agent`.
238239
Example:
239240

240241
```js
241-
var options = {
242+
constoptions= {
242243
hostname:'encrypted.google.com',
243244
port:443,
244245
path:'/',
@@ -248,8 +249,8 @@ var options = {
248249
agent:false
249250
};
250251

251-
var req =https.request(options, (res) => {
252-
...
252+
constreq=https.request(options, (res) => {
253+
//...
253254
});
254255
```
255256

0 commit comments

Comments
 (0)