From d3162da8ddc47b7e2ac08d7e2006ea52a2246f19 Mon Sep 17 00:00:00 2001 From: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> Date: Sun, 11 Apr 2021 03:49:43 +0430 Subject: [PATCH] typings: add JSDoc typings for http MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38191 Reviewed-By: Bradley Farias Reviewed-By: Michaƫl Zasso --- lib/http.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lib/http.js b/lib/http.js index 491162f9c4a172..38f1297be7921f 100644 --- a/lib/http.js +++ b/lib/http.js @@ -44,14 +44,65 @@ const { } = require('_http_server'); let maxHeaderSize; +/** + * Returns a new instance of `http.Server`. + * @param {{ + * IncomingMessage?: IncomingMessage; + * ServerResponse?: ServerResponse; + * insecureHTTPParser?: boolean; + * maxHeaderSize?: number; + * }} [opts] + * @param {Function} [requestListener] + * @returns {Server} + */ function createServer(opts, requestListener) { return new Server(opts, requestListener); } +/** + * @typedef {Object} HTTPRequestOptions + * @property {httpAgent.Agent | boolean} [agent] + * @property {string} [auth] + * @property {Function} [createConnection] + * @property {number} [defaultPort] + * @property {number} [family] + * @property {Object} [headers] + * @property {number} [hints] + * @property {string} [host] + * @property {string} [hostname] + * @property {boolean} [insecureHTTPParser] + * @property {string} [localAddress] + * @property {number} [localPort] + * @property {Function} [lookup] + * @property {number} [maxHeaderSize] + * @property {string} [method] + * @property {string} [path] + * @property {number} [port] + * @property {string} [protocol] + * @property {boolean} [setHost] + * @property {string} [socketPath] + * @property {number} [timeout] + * @property {AbortSignal} [signal] + */ + +/** + * Makes an HTTP request. + * @param {string | URL} url + * @param {HTTPRequestOptions} [options] + * @param {Function} [cb] + * @returns {ClientRequest} + */ function request(url, options, cb) { return new ClientRequest(url, options, cb); } +/** + * Makes a `GET` HTTP request. + * @param {string | URL} url + * @param {HTTPRequestOptions} [options] + * @param {Function} [cb] + * @returns {ClientRequest} + */ function get(url, options, cb) { const req = request(url, options, cb); req.end();