Skip to content

Commit 326bce9

Browse files
Francois Marierbnoordhuis
authored andcommitted
doc: reflect hostname v. host preference in examples
The documentation for http.request and https.request states that `hostname` is preferred over `host` so the code examples should use that option name.
1 parent 5f0a10a commit 326bce9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

doc/api/http.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ upload a file with a POST request, then write to the `ClientRequest` object.
505505
Example:
506506

507507
var options = {
508-
host: 'www.google.com',
508+
hostname: 'www.google.com',
509509
port: 80,
510510
path: '/upload',
511511
method: 'POST'
@@ -594,7 +594,7 @@ pool you can do something along the lines of:
594594

595595
Alternatively, you could just opt out of pooling entirely using `agent:false`:
596596

597-
http.get({host:'localhost', port:80, path:'/', agent:false}, function (res) {
597+
http.get({hostname:'localhost', port:80, path:'/', agent:false}, function (res) {
598598
// Do stuff
599599
})
600600

@@ -719,7 +719,7 @@ A client server pair that show you how to listen for the `connect` event.
719719
// make a request to a tunneling proxy
720720
var options = {
721721
port: 1337,
722-
host: '127.0.0.1',
722+
hostname: '127.0.0.1',
723723
method: 'CONNECT',
724724
path: 'www.google.com:80'
725725
};
@@ -776,7 +776,7 @@ A client server pair that show you how to listen for the `upgrade` event.
776776
// make a request
777777
var options = {
778778
port: 1337,
779-
host: '127.0.0.1',
779+
hostname: '127.0.0.1',
780780
headers: {
781781
'Connection': 'Upgrade',
782782
'Upgrade': 'websocket'

doc/api/https.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Example:
7171
var https = require('https');
7272

7373
var options = {
74-
host: 'encrypted.google.com',
74+
hostname: 'encrypted.google.com',
7575
port: 443,
7676
path: '/',
7777
method: 'GET'
@@ -137,7 +137,7 @@ In order to specify these options, use a custom `Agent`.
137137
Example:
138138

139139
var options = {
140-
host: 'encrypted.google.com',
140+
hostname: 'encrypted.google.com',
141141
port: 443,
142142
path: '/',
143143
method: 'GET',
@@ -155,7 +155,7 @@ Or does not use an `Agent`.
155155
Example:
156156

157157
var options = {
158-
host: 'encrypted.google.com',
158+
hostname: 'encrypted.google.com',
159159
port: 443,
160160
path: '/',
161161
method: 'GET',

0 commit comments

Comments
 (0)