Skip to content

Commit b956e32

Browse files
ameliavoncatgibfahn
authored andcommitted
doc: argument types for https methods
Ref: #9399 PR-URL: #11681 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 39d64ad commit b956e32

File tree

1 file changed

+37
-63
lines changed

1 file changed

+37
-63
lines changed

doc/api/https.md

+37-63
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,29 @@ added: v0.3.4
2121
This class is a subclass of `tls.Server` and emits events same as
2222
[`http.Server`][]. See [`http.Server`][] for more information.
2323

24-
### server.setTimeout(msecs, callback)
24+
### server.setTimeout([msecs][, callback])
2525
<!-- YAML
2626
added: v0.11.2
2727
-->
28+
- `msecs` {number} Defaults to 120000 (2 minutes).
29+
- `callback` {Function}
2830

2931
See [`http.Server#setTimeout()`][].
3032

31-
### server.timeout
33+
### server.timeout([msecs])
3234
<!-- YAML
3335
added: v0.11.2
3436
-->
37+
- `msecs` {number} Defaults to 120000 (2 minutes).
3538

3639
See [`http.Server#timeout`][].
3740

3841
## https.createServer(options[, requestListener])
3942
<!-- YAML
4043
added: v0.3.4
4144
-->
42-
43-
Returns a new HTTPS web server object. The `options` is similar to
44-
[`tls.createServer()`][]. The `requestListener` is a function which is
45-
automatically added to the `'request'` event.
45+
- `options` {Object} Accepts `options` from [`tls.createServer()`][] and [`tls.createSecureContext()`][].
46+
- `requestListener` {Function} A listener to be added to the `request` event.
4647

4748
Example:
4849

@@ -83,19 +84,33 @@ https.createServer(options, (req, res) => {
8384
<!-- YAML
8485
added: v0.1.90
8586
-->
87+
- `callback` {Function}
8688

8789
See [`http.close()`][] for details.
8890

8991
### server.listen(handle[, callback])
92+
- `handle` {Object}
93+
- `callback` {Function}
94+
9095
### server.listen(path[, callback])
91-
### server.listen(port[, host][, backlog][, callback])
96+
- `path` {string}
97+
- `callback` {Function}
98+
99+
### server.listen([port][, host][, backlog][, callback])
100+
- `port` {number}
101+
- `hostname` {string}
102+
- `backlog` {number}
103+
- `callback` {Function}
92104

93105
See [`http.listen()`][] for details.
94106

95-
## https.get(options, callback)
107+
## https.get(options[, callback])
96108
<!-- YAML
97109
added: v0.3.6
98110
-->
111+
- `options` {Object | string} Accepts the same `options` as
112+
[`https.request()`][], with the `method` always set to `GET`.
113+
- `callback` {Function}
99114

100115
Like [`http.get()`][] but for HTTPS.
101116

@@ -127,18 +142,27 @@ added: v0.5.9
127142

128143
Global instance of [`https.Agent`][] for all HTTPS client requests.
129144

130-
## https.request(options, callback)
145+
## https.request(options[, callback])
131146
<!-- YAML
132147
added: v0.3.6
133148
-->
149+
- `options` {Object | string} Accepts all `options` from [`http.request()`][],
150+
with some differences in default values:
151+
- `protocol` Defaults to `https:`
152+
- `port` Defaults to `443`.
153+
- `agent` Defaults to `https.globalAgent`.
154+
- `callback` {Function}
155+
134156

135157
Makes a request to a secure web server.
136158

159+
The following additional `options` from [`tls.connect()`][] are also accepted when using a
160+
custom [`Agent`][]:
161+
`pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`, `secureProtocol`, `servername`
162+
137163
`options` can be an object or a string. If `options` is a string, it is
138164
automatically parsed with [`url.parse()`][].
139165

140-
All options from [`http.request()`][] are valid.
141-
142166
Example:
143167

144168
```js
@@ -165,58 +189,7 @@ req.on('error', (e) => {
165189
});
166190
req.end();
167191
```
168-
169-
The options argument has the following options
170-
171-
- `host`: A domain name or IP address of the server to issue the request to.
172-
Defaults to `'localhost'`.
173-
- `hostname`: Alias for `host`. To support `url.parse()` `hostname` is
174-
preferred over `host`.
175-
- `family`: IP address family to use when resolving `host` and `hostname`.
176-
Valid values are `4` or `6`. When unspecified, both IP v4 and v6 will be
177-
used.
178-
- `port`: Port of remote server. Defaults to 443.
179-
- `localAddress`: Local interface to bind for network connections.
180-
- `socketPath`: Unix Domain Socket (use one of host:port or socketPath).
181-
- `method`: A string specifying the HTTP request method. Defaults to `'GET'`.
182-
- `path`: Request path. Defaults to `'/'`. Should include query string if any.
183-
E.G. `'/index.html?page=12'`. An exception is thrown when the request path
184-
contains illegal characters. Currently, only spaces are rejected but that
185-
may change in the future.
186-
- `headers`: An object containing request headers.
187-
- `auth`: Basic authentication i.e. `'user:password'` to compute an
188-
Authorization header.
189-
- `agent`: Controls [`Agent`][] behavior. When an Agent is used request will
190-
default to `Connection: keep-alive`. Possible values:
191-
- `undefined` (default): use [`globalAgent`][] for this host and port.
192-
- `Agent` object: explicitly use the passed in `Agent`.
193-
- `false`: opts out of connection pooling with an Agent, defaults request to
194-
`Connection: close`.
195-
196-
The following options from [`tls.connect()`][] can also be specified:
197-
198-
- `pfx`: Certificate, Private key and CA certificates to use for SSL. Default `null`.
199-
- `key`: Private key to use for SSL. Default `null`.
200-
- `passphrase`: A string of passphrase for the private key or pfx. Default `null`.
201-
- `cert`: Public x509 certificate to use. Default `null`.
202-
- `ca`: A string, [`Buffer`][] or array of strings or [`Buffer`][]s of trusted
203-
certificates in PEM format. If this is omitted several well known "root"
204-
CAs will be used, like VeriSign. These are used to authorize connections.
205-
- `ciphers`: A string describing the ciphers to use or exclude. Consult
206-
<https://www.openssl.org/docs/man1.0.2/apps/ciphers.html#CIPHER-LIST-FORMAT> for
207-
details on the format.
208-
- `rejectUnauthorized`: If `true`, the server certificate is verified against
209-
the list of supplied CAs. An `'error'` event is emitted if verification
210-
fails. Verification happens at the connection level, *before* the HTTP
211-
request is sent. Default `true`.
212-
- `secureProtocol`: The SSL method to use, e.g. `SSLv3_method` to force
213-
SSL version 3. The possible values depend on your installation of
214-
OpenSSL and are defined in the constant [`SSL_METHODS`][].
215-
- `servername`: Servername for SNI (Server Name Indication) TLS extension.
216-
217-
In order to specify these options, use a custom [`Agent`][].
218-
219-
Example:
192+
Example using options from [`tls.connect()`][]:
220193

221194
```js
222195
const options = {
@@ -270,4 +243,5 @@ const req = https.request(options, (res) => {
270243
[`SSL_METHODS`]: https://www.openssl.org/docs/man1.0.2/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS
271244
[`tls.connect()`]: tls.html#tls_tls_connect_options_callback
272245
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener
246+
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
273247
[`url.parse()`]: url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost

0 commit comments

Comments
 (0)