@@ -1794,15 +1794,20 @@ The `requestListener` is a function which is automatically
1794
1794
added to the [ ` 'request' ` ] [ ] event.
1795
1795
1796
1796
## http.get(options[ , callback] )
1797
+ ## http.get(url[ , options] [ , callback ] )
1797
1798
<!-- YAML
1798
1799
added: v0.3.6
1799
1800
changes:
1801
+ - version: REPLACEME
1802
+ pr-url: https://github.com/nodejs/node/pull/21616
1803
+ description: allow both url and options to be passed to `http.get()`
1800
1804
- version: v7.5.0
1801
1805
pr-url: https://github.com/nodejs/node/pull/10638
1802
1806
description: The `options` parameter can be a WHATWG `URL` object.
1803
1807
-->
1804
1808
1805
- * ` options ` {Object | string | URL} Accepts the same ` options ` as
1809
+ * ` url ` {string | URL}
1810
+ * ` options ` {Object} Accepts the same ` options ` as
1806
1811
[ ` http.request() ` ] [ ] , with the ` method ` always set to ` GET ` .
1807
1812
Properties that are inherited from the prototype are ignored.
1808
1813
* ` callback ` {Function}
@@ -1866,15 +1871,20 @@ Global instance of `Agent` which is used as the default for all HTTP client
1866
1871
requests.
1867
1872
1868
1873
## http.request(options[ , callback] )
1874
+ ## http.request(url[ , options] [ , callback ] )
1869
1875
<!-- YAML
1870
1876
added: v0.3.6
1871
1877
changes:
1878
+ - version: REPLACEME
1879
+ pr-url: https://github.com/nodejs/node/pull/21616
1880
+ description: allow both url and options to be passed to `http.request()`
1872
1881
- version: v7.5.0
1873
1882
pr-url: https://github.com/nodejs/node/pull/10638
1874
1883
description: The `options` parameter can be a WHATWG `URL` object.
1875
1884
-->
1876
1885
1877
- * ` options ` {Object | string | URL}
1886
+ * ` url ` {string | URL}
1887
+ * ` options ` {Object}
1878
1888
* ` protocol ` {string} Protocol to use. ** Default:** ` 'http:' ` .
1879
1889
* ` host ` {string} A domain name or IP address of the server to issue the
1880
1890
request to. ** Default:** ` 'localhost' ` .
@@ -1916,10 +1926,13 @@ changes:
1916
1926
Node.js maintains several connections per server to make HTTP requests.
1917
1927
This function allows one to transparently issue requests.
1918
1928
1919
- ` options ` can be an object, a string, or a [ ` URL ` ] [ ] object. If ` options ` is a
1929
+ ` url ` can be a string or a [ ` URL ` ] [ ] object. If ` url ` is a
1920
1930
string, it is automatically parsed with [ ` url.parse() ` ] [ ] . If it is a [ ` URL ` ] [ ]
1921
1931
object, it will be automatically converted to an ordinary ` options ` object.
1922
1932
1933
+ If both ` url ` and ` options ` are specified, the objects are merged, with the
1934
+ ` options ` properties taking precedence.
1935
+
1923
1936
The optional ` callback ` parameter will be added as a one-time listener for
1924
1937
the [ ` 'response' ` ] [ ] event.
1925
1938
0 commit comments