@@ -42,14 +42,65 @@ const { |
42 | 42 | } = require('_http_server'); |
43 | 43 | let maxHeaderSize; |
44 | 44 |
|
| 45 | +/** |
| 46 | + * Returns a new instance of `http.Server`. |
| 47 | + * @param {{ |
| 48 | + * IncomingMessage?: IncomingMessage; |
| 49 | + * ServerResponse?: ServerResponse; |
| 50 | + * insecureHTTPParser?: boolean; |
| 51 | + * maxHeaderSize?: number; |
| 52 | + * }} [opts] |
| 53 | + * @param {Function} [requestListener] |
| 54 | + * @returns {Server} |
| 55 | + */ |
45 | 56 | function createServer(opts, requestListener) { |
46 | 57 | return new Server(opts, requestListener); |
47 | 58 | } |
48 | 59 |
|
| 60 | +/** |
| 61 | + * @typedef {Object} HTTPRequestOptions |
| 62 | + * @property {httpAgent.Agent | boolean} [agent] |
| 63 | + * @property {string} [auth] |
| 64 | + * @property {Function} [createConnection] |
| 65 | + * @property {number} [defaultPort] |
| 66 | + * @property {number} [family] |
| 67 | + * @property {Object} [headers] |
| 68 | + * @property {number} [hints] |
| 69 | + * @property {string} [host] |
| 70 | + * @property {string} [hostname] |
| 71 | + * @property {boolean} [insecureHTTPParser] |
| 72 | + * @property {string} [localAddress] |
| 73 | + * @property {number} [localPort] |
| 74 | + * @property {Function} [lookup] |
| 75 | + * @property {number} [maxHeaderSize] |
| 76 | + * @property {string} [method] |
| 77 | + * @property {string} [path] |
| 78 | + * @property {number} [port] |
| 79 | + * @property {string} [protocol] |
| 80 | + * @property {boolean} [setHost] |
| 81 | + * @property {string} [socketPath] |
| 82 | + * @property {number} [timeout] |
| 83 | + * @property {AbortSignal} [signal] |
| 84 | + */ |
| 85 | + |
| 86 | +/** |
| 87 | + * Makes an HTTP request. |
| 88 | + * @param {string | URL} url |
| 89 | + * @param {HTTPRequestOptions} [options] |
| 90 | + * @param {Function} [cb] |
| 91 | + * @returns {ClientRequest} |
| 92 | + */ |
49 | 93 | function request(url, options, cb) { |
50 | 94 | return new ClientRequest(url, options, cb); |
51 | 95 | } |
52 | 96 |
|
| 97 | +/** |
| 98 | + * Makes a `GET` HTTP request. |
| 99 | + * @param {string | URL} url |
| 100 | + * @param {HTTPRequestOptions} [options] |
| 101 | + * @param {Function} [cb] |
| 102 | + * @returns {ClientRequest} |
| 103 | + */ |
53 | 104 | function get(url, options, cb) { |
54 | 105 | const req = request(url, options, cb); |
55 | 106 | req.end(); |
|