[node] ensure compatiblity between http.request and url.parse (#40430)

* [node] ensure compatiblity between http.request and url.parse

Ensure that output of url.parse() fits into http.request() as
indicated at https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback

* fix typo

Co-Authored-By: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
This commit is contained in:
Gerhard Stöbich
2019-11-18 21:45:00 +01:00
committed by Sheetal Nandi
parent 56faec0579
commit 8fa67cd896
2 changed files with 8 additions and 6 deletions

12
types/node/http.d.ts vendored
View File

@@ -69,18 +69,18 @@ declare module "http" {
}
interface ClientRequestArgs {
protocol?: string;
host?: string;
hostname?: string;
protocol?: string | null;
host?: string | null;
hostname?: string | null;
family?: number;
port?: number | string;
port?: number | string | null;
defaultPort?: number | string;
localAddress?: string;
socketPath?: string;
method?: string;
path?: string;
path?: string | null;
headers?: OutgoingHttpHeaders;
auth?: string;
auth?: string | null;
agent?: Agent | boolean;
_defaultAgent?: Agent;
timeout?: number;

View File

@@ -139,6 +139,8 @@ import * as net from 'net';
http.request({ agent: false });
http.request({ agent });
http.request({ agent: undefined });
// ensure compatibility with url.parse()
http.request(url.parse("http://www.example.org/xyz"));
}
{