summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSam Ruby <rubys@intertwingly.net>2018-07-01 11:00:24 -0400
committerMatteo Collina <hello@matteocollina.com>2018-07-13 14:09:39 +0100
commitf9b739ebbcb77bc5a0fc8e3d20ad2eae3285b039 (patch)
tree71ab1360234b41cda25bb1c6e07c321589ae7dba /doc
parent19bc893c7559ed53d17b9cdc372fc9614f2deda9 (diff)
downloadandroid-node-v8-f9b739ebbcb77bc5a0fc8e3d20ad2eae3285b039.tar.gz
android-node-v8-f9b739ebbcb77bc5a0fc8e3d20ad2eae3285b039.tar.bz2
android-node-v8-f9b739ebbcb77bc5a0fc8e3d20ad2eae3285b039.zip
http: allow url and options to be passed to http*.request and http*.get
Fixes: https://github.com/nodejs/node/issues/20795 PR-URL: https://github.com/nodejs/node/pull/21616 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/http.md19
-rw-r--r--doc/api/https.md14
2 files changed, 28 insertions, 5 deletions
diff --git a/doc/api/http.md b/doc/api/http.md
index 1776012f81..78f8bc4b6b 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -1796,15 +1796,20 @@ The `requestListener` is a function which is automatically
added to the [`'request'`][] event.
## http.get(options[, callback])
+## http.get(url[, options][, callback])
<!-- YAML
added: v0.3.6
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/21616
+ description: allow both url and options to be passed to `http.get()`
- version: v7.5.0
pr-url: https://github.com/nodejs/node/pull/10638
description: The `options` parameter can be a WHATWG `URL` object.
-->
-* `options` {Object | string | URL} Accepts the same `options` as
+* `url` {string | URL}
+* `options` {Object} Accepts the same `options` as
[`http.request()`][], with the `method` always set to `GET`.
Properties that are inherited from the prototype are ignored.
* `callback` {Function}
@@ -1868,15 +1873,20 @@ Global instance of `Agent` which is used as the default for all HTTP client
requests.
## http.request(options[, callback])
+## http.request(url[, options][, callback])
<!-- YAML
added: v0.3.6
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/21616
+ description: allow both url and options to be passed to `http.request()`
- version: v7.5.0
pr-url: https://github.com/nodejs/node/pull/10638
description: The `options` parameter can be a WHATWG `URL` object.
-->
-* `options` {Object | string | URL}
+* `url` {string | URL}
+* `options` {Object}
* `protocol` {string} Protocol to use. **Default:** `'http:'`.
* `host` {string} A domain name or IP address of the server to issue the
request to. **Default:** `'localhost'`.
@@ -1918,10 +1928,13 @@ changes:
Node.js maintains several connections per server to make HTTP requests.
This function allows one to transparently issue requests.
-`options` can be an object, a string, or a [`URL`][] object. If `options` is a
+`url` can be a string or a [`URL`][] object. If `url` is a
string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
object, it will be automatically converted to an ordinary `options` object.
+If both `url` and `options` are specified, the objects are merged, with the
+`options` properties taking precedence.
+
The optional `callback` parameter will be added as a one-time listener for
the [`'response'`][] event.
diff --git a/doc/api/https.md b/doc/api/https.md
index 4fdd2fe7bc..51e6e5c162 100644
--- a/doc/api/https.md
+++ b/doc/api/https.md
@@ -112,14 +112,19 @@ https.createServer(options, (req, res) => {
```
## https.get(options[, callback])
+## https.get(url[, options][, callback])
<!-- YAML
added: v0.3.6
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/21616
+ description: allow both url and options to be passed to `https.get()`
- version: v7.5.0
pr-url: https://github.com/nodejs/node/pull/10638
description: The `options` parameter can be a WHATWG `URL` object.
-->
-- `options` {Object | string | URL} Accepts the same `options` as
+- `url` {string | URL}
+- `options` {Object} Accepts the same `options` as
[`https.request()`][], with the `method` always set to `GET`.
- `callback` {Function}
@@ -155,9 +160,13 @@ added: v0.5.9
Global instance of [`https.Agent`][] for all HTTPS client requests.
## https.request(options[, callback])
+## https.request(url[, options][, callback])
<!-- YAML
added: v0.3.6
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/21616
+ description: allow both url and options to be passed to `https.request()`
- version: v9.3.0
pr-url: https://github.com/nodejs/node/pull/14903
description: The `options` parameter can now include `clientCertEngine`.
@@ -165,7 +174,8 @@ changes:
pr-url: https://github.com/nodejs/node/pull/10638
description: The `options` parameter can be a WHATWG `URL` object.
-->
-- `options` {Object | string | URL} Accepts all `options` from
+- `url` {string | URL}
+- `options` {Object} Accepts all `options` from
[`http.request()`][], with some differences in default values:
- `protocol` **Default:** `'https:'`
- `port` **Default:** `443`