Skip to content

Commit f6b0309

Browse files
ameliavoncatjasnell
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 53f3869 commit f6b0309

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

@@ -82,19 +83,33 @@ https.createServer(options, (req, res) => {
8283
<!-- YAML
8384
added: v0.1.90
8485
-->
86+
- `callback` {Function}
8587

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

8890
### server.listen(handle[, callback])
91+
- `handle` {Object}
92+
- `callback` {Function}
93+
8994
### server.listen(path[, callback])
90-
### server.listen(port[, host][, backlog][, callback])
95+
- `path` {string}
96+
- `callback` {Function}
97+
98+
### server.listen([port][, host][, backlog][, callback])
99+
- `port` {number}
100+
- `hostname` {string}
101+
- `backlog` {number}
102+
- `callback` {Function}
91103

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

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

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

@@ -126,18 +141,27 @@ added: v0.5.9
126141

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

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

134156
Makes a request to a secure web server.
135157

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

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

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

220193
```js
221194
var options = {
@@ -269,4 +242,5 @@ var req = https.request(options, (res) => {
269242
[`SSL_METHODS`]: https://www.openssl.org/docs/man1.0.2/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS
270243
[`tls.connect()`]: tls.html#tls_tls_connect_options_callback
271244
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener
245+
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
272246
[`url.parse()`]: url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost

0 commit comments

Comments
 (0)