@@ -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
@@ -82,19 +83,33 @@ https.createServer(options, (req, res) => {
82
83
<!-- YAML
83
84
added: v0.1.90
84
85
-->
86
+ - ` callback ` {Function}
85
87
86
88
See [ ` http.close() ` ] [ ] for details.
87
89
88
90
### server.listen(handle[ , callback] )
91
+ - ` handle ` {Object}
92
+ - ` callback ` {Function}
93
+
89
94
### 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}
91
103
92
104
See [ ` http.listen() ` ] [ ] for details.
93
105
94
- ## https.get(options, callback)
106
+ ## https.get(options[ , callback] )
95
107
<!-- YAML
96
108
added: v0.3.6
97
109
-->
110
+ - ` options ` {Object | string} Accepts the same ` options ` as
111
+ [ ` https.request() ` ] [ ] , with the ` method ` always set to ` GET ` .
112
+ - ` callback ` {Function}
98
113
99
114
Like [ ` http.get() ` ] [ ] but for HTTPS.
100
115
@@ -126,18 +141,27 @@ added: v0.5.9
126
141
127
142
Global instance of [ ` https.Agent ` ] [ ] for all HTTPS client requests.
128
143
129
- ## https.request(options, callback)
144
+ ## https.request(options[ , callback] )
130
145
<!-- YAML
131
146
added: v0.3.6
132
147
-->
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
+
133
155
134
156
Makes a request to a secure web server.
135
157
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
+
136
162
` options ` can be an object or a string. If ` options ` is a string, it is
137
163
automatically parsed with [ ` url.parse() ` ] [ ] .
138
164
139
- All options from [ ` http.request() ` ] [ ] are valid.
140
-
141
165
Example:
142
166
143
167
``` js
@@ -164,58 +188,7 @@ req.on('error', (e) => {
164
188
});
165
189
req .end ();
166
190
```
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() ` ] [ ] :
219
192
220
193
``` js
221
194
var options = {
@@ -269,4 +242,5 @@ var req = https.request(options, (res) => {
269
242
[ `SSL_METHODS` ] : https://www.openssl.org/docs/man1.0.2/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS
270
243
[ `tls.connect()` ] : tls.html#tls_tls_connect_options_callback
271
244
[ `tls.createServer()` ] : tls.html#tls_tls_createserver_options_secureconnectionlistener
245
+ [ `tls.createSecureContext()` ] : tls.html#tls_tls_createsecurecontext_options
272
246
[ `url.parse()` ] : url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
0 commit comments