@@ -115,15 +115,20 @@ See [`http.listen()`][] for details.
115
115
## https.get(options[ , callback] )
116
116
<!-- YAML
117
117
added: v0.3.6
118
+ changes:
119
+ - version: v7.5.0
120
+ pr-url: https://github.com/nodejs/node/pull/10638
121
+ description: The `options` parameter can be a WHATWG `URL` object.
118
122
-->
119
- - ` options ` {Object | string} Accepts the same ` options ` as
123
+ - ` options ` {Object | string | URL } Accepts the same ` options ` as
120
124
[ ` https.request() ` ] [ ] , with the ` method ` always set to ` GET ` .
121
125
- ` callback ` {Function}
122
126
123
127
Like [ ` http.get() ` ] [ ] but for HTTPS.
124
128
125
- ` options ` can be an object or a string. If ` options ` is a string, it is
126
- automatically parsed with [ ` url.parse() ` ] [ ] .
129
+ ` options ` can be an object, a string, or a [ ` URL ` ] [ ] object. If ` options ` is a
130
+ string, it is automatically parsed with [ ` url.parse() ` ] [ ] . If it is a [ ` URL ` ] [ ]
131
+ object, it will be automatically converted to an ordinary ` options ` object.
127
132
128
133
Example:
129
134
@@ -153,8 +158,12 @@ Global instance of [`https.Agent`][] for all HTTPS client requests.
153
158
## https.request(options[ , callback] )
154
159
<!-- YAML
155
160
added: v0.3.6
161
+ changes:
162
+ - version: v7.5.0
163
+ pr-url: https://github.com/nodejs/node/pull/10638
164
+ description: The `options` parameter can be a WHATWG `URL` object.
156
165
-->
157
- - ` options ` {Object | string} Accepts all ` options ` from [ ` http.request() ` ] [ ] ,
166
+ - ` options ` {Object | string | URL } Accepts all ` options ` from [ ` http.request() ` ] [ ] ,
158
167
with some differences in default values:
159
168
- ` protocol ` Defaults to ` https: `
160
169
- ` port ` Defaults to ` 443 ` .
@@ -168,8 +177,9 @@ The following additional `options` from [`tls.connect()`][] are also accepted wh
168
177
custom [ ` Agent ` ] [ ] :
169
178
` pfx ` , ` key ` , ` passphrase ` , ` cert ` , ` ca ` , ` ciphers ` , ` rejectUnauthorized ` , ` secureProtocol ` , ` servername `
170
179
171
- ` options ` can be an object or a string. If ` options ` is a string, it is
172
- automatically parsed with [ ` url.parse() ` ] [ ] .
180
+ ` options ` can be an object, a string, or a [ ` URL ` ] [ ] object. If ` options ` is a
181
+ string, it is automatically parsed with [ ` url.parse() ` ] [ ] . If it is a [ ` URL ` ] [ ]
182
+ object, it will be automatically converted to an ordinary ` options ` object.
173
183
174
184
Example:
175
185
@@ -235,7 +245,20 @@ const req = https.request(options, (res) => {
235
245
});
236
246
```
237
247
248
+ Example using a [ ` URL ` ] [ ] as ` options ` :
249
+
250
+ ``` js
251
+ const { URL } = require (' url' );
252
+
253
+ const options = new URL (
' https://abc:[email protected] ' );
254
+
255
+ const req = https .request (options, (res ) => {
256
+ // ...
257
+ });
258
+ ```
259
+
238
260
[ `Agent` ] : #https_class_https_agent
261
+ [ `URL` ] : url.html#url_the_whatwg_url_api
239
262
[ `http.Agent` ] : http.html#http_class_http_agent
240
263
[ `http.Server#keepAliveTimeout` ] : http.html#http_server_keepalivetimeout
241
264
[ `http.Server#setTimeout()` ] : http.html#http_server_settimeout_msecs_callback
0 commit comments