@@ -21,28 +21,29 @@ added: v0.3.4
21
21
This class is a subclass of ` tls.Server ` and emits events same as
22
22
[ ` http.Server ` ] [ ] . See [ ` http.Server ` ] [ ] for more information.
23
23
24
- ### server.setTimeout(msecs, callback)
24
+ ### server.setTimeout([ msecs] [ , callback ] )
25
25
<!-- YAML
26
26
added: v0.11.2
27
27
-->
28
+ - ` msecs ` {number} Defaults to 120000 (2 minutes).
29
+ - ` callback ` {Function}
28
30
29
31
See [ ` http.Server#setTimeout() ` ] [ ] .
30
32
31
- ### server.timeout
33
+ ### server.timeout( [ msecs ] )
32
34
<!-- YAML
33
35
added: v0.11.2
34
36
-->
37
+ - ` msecs ` {number} Defaults to 120000 (2 minutes).
35
38
36
39
See [ ` http.Server#timeout ` ] [ ] .
37
40
38
41
## https.createServer(options[ , requestListener] )
39
42
<!-- YAML
40
43
added: v0.3.4
41
44
-->
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.
46
47
47
48
Example:
48
49
@@ -83,19 +84,33 @@ https.createServer(options, (req, res) => {
83
84
<!-- YAML
84
85
added: v0.1.90
85
86
-->
87
+ - ` callback ` {Function}
86
88
87
89
See [ ` http.close() ` ] [ ] for details.
88
90
89
91
### server.listen(handle[ , callback] )
92
+ - ` handle ` {Object}
93
+ - ` callback ` {Function}
94
+
90
95
### 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}
92
104
93
105
See [ ` http.listen() ` ] [ ] for details.
94
106
95
- ## https.get(options, callback)
107
+ ## https.get(options[ , callback] )
96
108
<!-- YAML
97
109
added: v0.3.6
98
110
-->
111
+ - ` options ` {Object | string} Accepts the same ` options ` as
112
+ [ ` https.request() ` ] [ ] , with the ` method ` always set to ` GET ` .
113
+ - ` callback ` {Function}
99
114
100
115
Like [ ` http.get() ` ] [ ] but for HTTPS.
101
116
@@ -127,18 +142,27 @@ added: v0.5.9
127
142
128
143
Global instance of [ ` https.Agent ` ] [ ] for all HTTPS client requests.
129
144
130
- ## https.request(options, callback)
145
+ ## https.request(options[ , callback] )
131
146
<!-- YAML
132
147
added: v0.3.6
133
148
-->
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
+
134
156
135
157
Makes a request to a secure web server.
136
158
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
+
137
163
` options ` can be an object or a string. If ` options ` is a string, it is
138
164
automatically parsed with [ ` url.parse() ` ] [ ] .
139
165
140
- All options from [ ` http.request() ` ] [ ] are valid.
141
-
142
166
Example:
143
167
144
168
``` js
@@ -165,58 +189,7 @@ req.on('error', (e) => {
165
189
});
166
190
req .end ();
167
191
```
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() ` ] [ ] :
220
193
221
194
``` js
222
195
const options = {
@@ -270,4 +243,5 @@ const req = https.request(options, (res) => {
270
243
[ `SSL_METHODS` ] : https://www.openssl.org/docs/man1.0.2/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS
271
244
[ `tls.connect()` ] : tls.html#tls_tls_connect_options_callback
272
245
[ `tls.createServer()` ] : tls.html#tls_tls_createserver_options_secureconnectionlistener
246
+ [ `tls.createSecureContext()` ] : tls.html#tls_tls_createsecurecontext_options
273
247
[ `url.parse()` ] : url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
0 commit comments