Skip to content

Commit d3162da

Browse files
VoltrexKeyvatargos
authored andcommitted
typings: add JSDoc typings for http
PR-URL: #38191 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent fc20e83 commit d3162da

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

‎lib/http.js‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,65 @@ const{
4444
}=require('_http_server');
4545
letmaxHeaderSize;
4646

47+
/**
48+
* Returns a new instance of `http.Server`.
49+
* @param{{
50+
* IncomingMessage?: IncomingMessage;
51+
* ServerResponse?: ServerResponse;
52+
* insecureHTTPParser?: boolean;
53+
* maxHeaderSize?: number;
54+
* }} [opts]
55+
* @param{Function} [requestListener]
56+
* @returns{Server}
57+
*/
4758
functioncreateServer(opts,requestListener){
4859
returnnewServer(opts,requestListener);
4960
}
5061

62+
/**
63+
* @typedef{Object} HTTPRequestOptions
64+
* @property{httpAgent.Agent | boolean} [agent]
65+
* @property{string} [auth]
66+
* @property{Function} [createConnection]
67+
* @property{number} [defaultPort]
68+
* @property{number} [family]
69+
* @property{Object} [headers]
70+
* @property{number} [hints]
71+
* @property{string} [host]
72+
* @property{string} [hostname]
73+
* @property{boolean} [insecureHTTPParser]
74+
* @property{string} [localAddress]
75+
* @property{number} [localPort]
76+
* @property{Function} [lookup]
77+
* @property{number} [maxHeaderSize]
78+
* @property{string} [method]
79+
* @property{string} [path]
80+
* @property{number} [port]
81+
* @property{string} [protocol]
82+
* @property{boolean} [setHost]
83+
* @property{string} [socketPath]
84+
* @property{number} [timeout]
85+
* @property{AbortSignal} [signal]
86+
*/
87+
88+
/**
89+
* Makes an HTTP request.
90+
* @param{string | URL} url
91+
* @param{HTTPRequestOptions} [options]
92+
* @param{Function} [cb]
93+
* @returns{ClientRequest}
94+
*/
5195
functionrequest(url,options,cb){
5296
returnnewClientRequest(url,options,cb);
5397
}
5498

99+
/**
100+
* Makes a `GET` HTTP request.
101+
* @param{string | URL} url
102+
* @param{HTTPRequestOptions} [options]
103+
* @param{Function} [cb]
104+
* @returns{ClientRequest}
105+
*/
55106
functionget(url,options,cb){
56107
constreq=request(url,options,cb);
57108
req.end();

0 commit comments

Comments
(0)