Skip to content

Commit f60b455

Browse files
vsemozhetbytitaloacasas
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 74d0266 commit f60b455

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

doc/api/https.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ const https = require('https');
7070
const fs = require('fs');
7171

7272
const options = {
73-
pfx: fs.readFileSync('server.pfx')
73+
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
74+
passphrase: 'sample'
7475
};
7576

7677
https.createServer(options, (req, res) => {
@@ -167,14 +168,14 @@ Example:
167168
```js
168169
const https = require('https');
169170

170-
var options = {
171+
const options = {
171172
hostname: 'encrypted.google.com',
172173
port: 443,
173174
path: '/',
174175
method: 'GET'
175176
};
176177

177-
var req = https.request(options, (res) => {
178+
const req = https.request(options, (res) => {
178179
console.log('statusCode:', res.statusCode);
179180
console.log('headers:', res.headers);
180181

@@ -191,7 +192,7 @@ req.end();
191192
Example using options from [`tls.connect()`][]:
192193

193194
```js
194-
var options = {
195+
const options = {
195196
hostname: 'encrypted.google.com',
196197
port: 443,
197198
path: '/',
@@ -201,8 +202,8 @@ var options = {
201202
};
202203
options.agent = new https.Agent(options);
203204

204-
var req = https.request(options, (res) => {
205-
...
205+
const req = https.request(options, (res) => {
206+
// ...
206207
});
207208
```
208209

@@ -211,7 +212,7 @@ Alternatively, opt out of connection pooling by not using an `Agent`.
211212
Example:
212213

213214
```js
214-
var options = {
215+
const options = {
215216
hostname: 'encrypted.google.com',
216217
port: 443,
217218
path: '/',
@@ -221,8 +222,8 @@ var options = {
221222
agent: false
222223
};
223224

224-
var req = https.request(options, (res) => {
225-
...
225+
const req = https.request(options, (res) => {
226+
// ...
226227
});
227228
```
228229

0 commit comments

Comments
 (0)