Skip to content

Commit

Permalink
doc: modernize and fix code examples in https.md
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed Apr 19, 2017
1 parent c0d9b1c commit 811ccdf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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: '/',
Expand All @@ -228,8 +229,8 @@ var options = {
};
options.agent = new https.Agent(options);

var req = https.request(options, (res) => {
...
const req = https.request(options, (res) => {
// ...
});
```

Expand All @@ -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: '/',
Expand All @@ -248,8 +249,8 @@ var options = {
agent: false
};

var req = https.request(options, (res) => {
...
const req = https.request(options, (res) => {
// ...
});
```

Expand Down

0 comments on commit 811ccdf

Please sign in to comment.