11cb0ef41Sopenharmony_ci{ 21cb0ef41Sopenharmony_ci "type": "module", 31cb0ef41Sopenharmony_ci "source": "doc/api/https.md", 41cb0ef41Sopenharmony_ci "modules": [ 51cb0ef41Sopenharmony_ci { 61cb0ef41Sopenharmony_ci "textRaw": "HTTPS", 71cb0ef41Sopenharmony_ci "name": "https", 81cb0ef41Sopenharmony_ci "introduced_in": "v0.10.0", 91cb0ef41Sopenharmony_ci "stability": 2, 101cb0ef41Sopenharmony_ci "stabilityText": "Stable", 111cb0ef41Sopenharmony_ci "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v18.20.1/lib/https.js\">lib/https.js</a></p>\n<p>HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a\nseparate module.</p>", 121cb0ef41Sopenharmony_ci "modules": [ 131cb0ef41Sopenharmony_ci { 141cb0ef41Sopenharmony_ci "textRaw": "Determining if crypto support is unavailable", 151cb0ef41Sopenharmony_ci "name": "determining_if_crypto_support_is_unavailable", 161cb0ef41Sopenharmony_ci "desc": "<p>It is possible for Node.js to be built without including support for the\n<code>node:crypto</code> module. In such cases, attempting to <code>import</code> from <code>https</code> or\ncalling <code>require('node:https')</code> will result in an error being thrown.</p>\n<p>When using CommonJS, the error thrown can be caught using try/catch:</p>\n<!-- eslint-skip -->\n<pre><code class=\"language-cjs\">let https;\ntry {\n https = require('node:https');\n} catch (err) {\n console.error('https support is disabled!');\n}\n</code></pre>\n<p>When using the lexical ESM <code>import</code> keyword, the error can only be\ncaught if a handler for <code>process.on('uncaughtException')</code> is registered\n<em>before</em> any attempt to load the module is made (using, for instance,\na preload module).</p>\n<p>When using ESM, if there is a chance that the code may be run on a build\nof Node.js where crypto support is not enabled, consider using the\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import\"><code>import()</code></a> function instead of the lexical <code>import</code> keyword:</p>\n<pre><code class=\"language-mjs\">let https;\ntry {\n https = await import('node:https');\n} catch (err) {\n console.error('https support is disabled!');\n}\n</code></pre>", 171cb0ef41Sopenharmony_ci "type": "module", 181cb0ef41Sopenharmony_ci "displayName": "Determining if crypto support is unavailable" 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci ], 211cb0ef41Sopenharmony_ci "classes": [ 221cb0ef41Sopenharmony_ci { 231cb0ef41Sopenharmony_ci "textRaw": "Class: `https.Agent`", 241cb0ef41Sopenharmony_ci "type": "class", 251cb0ef41Sopenharmony_ci "name": "https.Agent", 261cb0ef41Sopenharmony_ci "meta": { 271cb0ef41Sopenharmony_ci "added": [ 281cb0ef41Sopenharmony_ci "v0.4.5" 291cb0ef41Sopenharmony_ci ], 301cb0ef41Sopenharmony_ci "changes": [ 311cb0ef41Sopenharmony_ci { 321cb0ef41Sopenharmony_ci "version": "v5.3.0", 331cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/4252", 341cb0ef41Sopenharmony_ci "description": "support `0` `maxCachedSessions` to disable TLS session caching." 351cb0ef41Sopenharmony_ci }, 361cb0ef41Sopenharmony_ci { 371cb0ef41Sopenharmony_ci "version": "v2.5.0", 381cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/2228", 391cb0ef41Sopenharmony_ci "description": "parameter `maxCachedSessions` added to `options` for TLS sessions reuse." 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci ] 421cb0ef41Sopenharmony_ci }, 431cb0ef41Sopenharmony_ci "desc": "<p>An <a href=\"#class-httpsagent\"><code>Agent</code></a> object for HTTPS similar to <a href=\"http.html#class-httpagent\"><code>http.Agent</code></a>. See\n<a href=\"#httpsrequestoptions-callback\"><code>https.request()</code></a> for more information.</p>", 441cb0ef41Sopenharmony_ci "signatures": [ 451cb0ef41Sopenharmony_ci { 461cb0ef41Sopenharmony_ci "params": [ 471cb0ef41Sopenharmony_ci { 481cb0ef41Sopenharmony_ci "textRaw": "`options` {Object} Set of configurable options to set on the agent. Can have the same fields as for [`http.Agent(options)`][], and", 491cb0ef41Sopenharmony_ci "name": "options", 501cb0ef41Sopenharmony_ci "type": "Object", 511cb0ef41Sopenharmony_ci "desc": "Set of configurable options to set on the agent. Can have the same fields as for [`http.Agent(options)`][], and", 521cb0ef41Sopenharmony_ci "options": [ 531cb0ef41Sopenharmony_ci { 541cb0ef41Sopenharmony_ci "textRaw": "`maxCachedSessions` {number} maximum number of TLS cached sessions. Use `0` to disable TLS session caching. **Default:** `100`.", 551cb0ef41Sopenharmony_ci "name": "maxCachedSessions", 561cb0ef41Sopenharmony_ci "type": "number", 571cb0ef41Sopenharmony_ci "default": "`100`", 581cb0ef41Sopenharmony_ci "desc": "maximum number of TLS cached sessions. Use `0` to disable TLS session caching." 591cb0ef41Sopenharmony_ci }, 601cb0ef41Sopenharmony_ci { 611cb0ef41Sopenharmony_ci "textRaw": "`servername` {string} the value of [Server Name Indication extension][sni wiki] to be sent to the server. Use empty string `''` to disable sending the extension. **Default:** host name of the target server, unless the target server is specified using an IP address, in which case the default is `''` (no extension).See [`Session Resumption`][] for information about TLS session reuse.", 621cb0ef41Sopenharmony_ci "name": "servername", 631cb0ef41Sopenharmony_ci "type": "string", 641cb0ef41Sopenharmony_ci "default": "host name of the target server, unless the target server is specified using an IP address, in which case the default is `''` (no extension).See [`Session Resumption`][] for information about TLS session reuse", 651cb0ef41Sopenharmony_ci "desc": "the value of [Server Name Indication extension][sni wiki] to be sent to the server. Use empty string `''` to disable sending the extension." 661cb0ef41Sopenharmony_ci } 671cb0ef41Sopenharmony_ci ] 681cb0ef41Sopenharmony_ci } 691cb0ef41Sopenharmony_ci ] 701cb0ef41Sopenharmony_ci } 711cb0ef41Sopenharmony_ci ] 721cb0ef41Sopenharmony_ci }, 731cb0ef41Sopenharmony_ci { 741cb0ef41Sopenharmony_ci "textRaw": "Class: `https.Server`", 751cb0ef41Sopenharmony_ci "type": "class", 761cb0ef41Sopenharmony_ci "name": "https.Server", 771cb0ef41Sopenharmony_ci "meta": { 781cb0ef41Sopenharmony_ci "added": [ 791cb0ef41Sopenharmony_ci "v0.3.4" 801cb0ef41Sopenharmony_ci ], 811cb0ef41Sopenharmony_ci "changes": [] 821cb0ef41Sopenharmony_ci }, 831cb0ef41Sopenharmony_ci "desc": "<ul>\n<li>Extends: <a href=\"tls.html#class-tlsserver\" class=\"type\"><tls.Server></a></li>\n</ul>\n<p>See <a href=\"http.html#class-httpserver\"><code>http.Server</code></a> for more information.</p>", 841cb0ef41Sopenharmony_ci "methods": [ 851cb0ef41Sopenharmony_ci { 861cb0ef41Sopenharmony_ci "textRaw": "`server.close([callback])`", 871cb0ef41Sopenharmony_ci "type": "method", 881cb0ef41Sopenharmony_ci "name": "close", 891cb0ef41Sopenharmony_ci "meta": { 901cb0ef41Sopenharmony_ci "added": [ 911cb0ef41Sopenharmony_ci "v0.1.90" 921cb0ef41Sopenharmony_ci ], 931cb0ef41Sopenharmony_ci "changes": [] 941cb0ef41Sopenharmony_ci }, 951cb0ef41Sopenharmony_ci "signatures": [ 961cb0ef41Sopenharmony_ci { 971cb0ef41Sopenharmony_ci "return": { 981cb0ef41Sopenharmony_ci "textRaw": "Returns: {https.Server}", 991cb0ef41Sopenharmony_ci "name": "return", 1001cb0ef41Sopenharmony_ci "type": "https.Server" 1011cb0ef41Sopenharmony_ci }, 1021cb0ef41Sopenharmony_ci "params": [ 1031cb0ef41Sopenharmony_ci { 1041cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 1051cb0ef41Sopenharmony_ci "name": "callback", 1061cb0ef41Sopenharmony_ci "type": "Function" 1071cb0ef41Sopenharmony_ci } 1081cb0ef41Sopenharmony_ci ] 1091cb0ef41Sopenharmony_ci } 1101cb0ef41Sopenharmony_ci ], 1111cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#serverclosecallback\"><code>server.close()</code></a> in the <code>node:http</code> module.</p>" 1121cb0ef41Sopenharmony_ci }, 1131cb0ef41Sopenharmony_ci { 1141cb0ef41Sopenharmony_ci "textRaw": "`server.closeAllConnections()`", 1151cb0ef41Sopenharmony_ci "type": "method", 1161cb0ef41Sopenharmony_ci "name": "closeAllConnections", 1171cb0ef41Sopenharmony_ci "meta": { 1181cb0ef41Sopenharmony_ci "added": [ 1191cb0ef41Sopenharmony_ci "v18.2.0" 1201cb0ef41Sopenharmony_ci ], 1211cb0ef41Sopenharmony_ci "changes": [] 1221cb0ef41Sopenharmony_ci }, 1231cb0ef41Sopenharmony_ci "signatures": [ 1241cb0ef41Sopenharmony_ci { 1251cb0ef41Sopenharmony_ci "params": [] 1261cb0ef41Sopenharmony_ci } 1271cb0ef41Sopenharmony_ci ], 1281cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#servercloseallconnections\"><code>server.closeAllConnections()</code></a> in the <code>node:http</code> module.</p>" 1291cb0ef41Sopenharmony_ci }, 1301cb0ef41Sopenharmony_ci { 1311cb0ef41Sopenharmony_ci "textRaw": "`server.closeIdleConnections()`", 1321cb0ef41Sopenharmony_ci "type": "method", 1331cb0ef41Sopenharmony_ci "name": "closeIdleConnections", 1341cb0ef41Sopenharmony_ci "meta": { 1351cb0ef41Sopenharmony_ci "added": [ 1361cb0ef41Sopenharmony_ci "v18.2.0" 1371cb0ef41Sopenharmony_ci ], 1381cb0ef41Sopenharmony_ci "changes": [] 1391cb0ef41Sopenharmony_ci }, 1401cb0ef41Sopenharmony_ci "signatures": [ 1411cb0ef41Sopenharmony_ci { 1421cb0ef41Sopenharmony_ci "params": [] 1431cb0ef41Sopenharmony_ci } 1441cb0ef41Sopenharmony_ci ], 1451cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#servercloseidleconnections\"><code>server.closeIdleConnections()</code></a> in the <code>node:http</code> module.</p>" 1461cb0ef41Sopenharmony_ci }, 1471cb0ef41Sopenharmony_ci { 1481cb0ef41Sopenharmony_ci "textRaw": "`server.listen()`", 1491cb0ef41Sopenharmony_ci "type": "method", 1501cb0ef41Sopenharmony_ci "name": "listen", 1511cb0ef41Sopenharmony_ci "signatures": [ 1521cb0ef41Sopenharmony_ci { 1531cb0ef41Sopenharmony_ci "params": [] 1541cb0ef41Sopenharmony_ci } 1551cb0ef41Sopenharmony_ci ], 1561cb0ef41Sopenharmony_ci "desc": "<p>Starts the HTTPS server listening for encrypted connections.\nThis method is identical to <a href=\"net.html#serverlisten\"><code>server.listen()</code></a> from <a href=\"net.html#class-netserver\"><code>net.Server</code></a>.</p>" 1571cb0ef41Sopenharmony_ci }, 1581cb0ef41Sopenharmony_ci { 1591cb0ef41Sopenharmony_ci "textRaw": "`server.setTimeout([msecs][, callback])`", 1601cb0ef41Sopenharmony_ci "type": "method", 1611cb0ef41Sopenharmony_ci "name": "setTimeout", 1621cb0ef41Sopenharmony_ci "meta": { 1631cb0ef41Sopenharmony_ci "added": [ 1641cb0ef41Sopenharmony_ci "v0.11.2" 1651cb0ef41Sopenharmony_ci ], 1661cb0ef41Sopenharmony_ci "changes": [] 1671cb0ef41Sopenharmony_ci }, 1681cb0ef41Sopenharmony_ci "signatures": [ 1691cb0ef41Sopenharmony_ci { 1701cb0ef41Sopenharmony_ci "return": { 1711cb0ef41Sopenharmony_ci "textRaw": "Returns: {https.Server}", 1721cb0ef41Sopenharmony_ci "name": "return", 1731cb0ef41Sopenharmony_ci "type": "https.Server" 1741cb0ef41Sopenharmony_ci }, 1751cb0ef41Sopenharmony_ci "params": [ 1761cb0ef41Sopenharmony_ci { 1771cb0ef41Sopenharmony_ci "textRaw": "`msecs` {number} **Default:** `120000` (2 minutes)", 1781cb0ef41Sopenharmony_ci "name": "msecs", 1791cb0ef41Sopenharmony_ci "type": "number", 1801cb0ef41Sopenharmony_ci "default": "`120000` (2 minutes)" 1811cb0ef41Sopenharmony_ci }, 1821cb0ef41Sopenharmony_ci { 1831cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 1841cb0ef41Sopenharmony_ci "name": "callback", 1851cb0ef41Sopenharmony_ci "type": "Function" 1861cb0ef41Sopenharmony_ci } 1871cb0ef41Sopenharmony_ci ] 1881cb0ef41Sopenharmony_ci } 1891cb0ef41Sopenharmony_ci ], 1901cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#serversettimeoutmsecs-callback\"><code>server.setTimeout()</code></a> in the <code>node:http</code> module.</p>" 1911cb0ef41Sopenharmony_ci } 1921cb0ef41Sopenharmony_ci ], 1931cb0ef41Sopenharmony_ci "properties": [ 1941cb0ef41Sopenharmony_ci { 1951cb0ef41Sopenharmony_ci "textRaw": "`headersTimeout` {number} **Default:** `60000`", 1961cb0ef41Sopenharmony_ci "type": "number", 1971cb0ef41Sopenharmony_ci "name": "headersTimeout", 1981cb0ef41Sopenharmony_ci "meta": { 1991cb0ef41Sopenharmony_ci "added": [ 2001cb0ef41Sopenharmony_ci "v11.3.0" 2011cb0ef41Sopenharmony_ci ], 2021cb0ef41Sopenharmony_ci "changes": [] 2031cb0ef41Sopenharmony_ci }, 2041cb0ef41Sopenharmony_ci "default": "`60000`", 2051cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#serverheaderstimeout\"><code>server.headersTimeout</code></a> in the <code>node:http</code> module.</p>" 2061cb0ef41Sopenharmony_ci }, 2071cb0ef41Sopenharmony_ci { 2081cb0ef41Sopenharmony_ci "textRaw": "`maxHeadersCount` {number} **Default:** `2000`", 2091cb0ef41Sopenharmony_ci "type": "number", 2101cb0ef41Sopenharmony_ci "name": "maxHeadersCount", 2111cb0ef41Sopenharmony_ci "default": "`2000`", 2121cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#servermaxheaderscount\"><code>server.maxHeadersCount</code></a> in the <code>node:http</code> module.</p>" 2131cb0ef41Sopenharmony_ci }, 2141cb0ef41Sopenharmony_ci { 2151cb0ef41Sopenharmony_ci "textRaw": "`requestTimeout` {number} **Default:** `300000`", 2161cb0ef41Sopenharmony_ci "type": "number", 2171cb0ef41Sopenharmony_ci "name": "requestTimeout", 2181cb0ef41Sopenharmony_ci "meta": { 2191cb0ef41Sopenharmony_ci "added": [ 2201cb0ef41Sopenharmony_ci "v14.11.0" 2211cb0ef41Sopenharmony_ci ], 2221cb0ef41Sopenharmony_ci "changes": [ 2231cb0ef41Sopenharmony_ci { 2241cb0ef41Sopenharmony_ci "version": "v18.0.0", 2251cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/41263", 2261cb0ef41Sopenharmony_ci "description": "The default request timeout changed from no timeout to 300s (5 minutes)." 2271cb0ef41Sopenharmony_ci } 2281cb0ef41Sopenharmony_ci ] 2291cb0ef41Sopenharmony_ci }, 2301cb0ef41Sopenharmony_ci "default": "`300000`", 2311cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#serverrequesttimeout\"><code>server.requestTimeout</code></a> in the <code>node:http</code> module.</p>" 2321cb0ef41Sopenharmony_ci }, 2331cb0ef41Sopenharmony_ci { 2341cb0ef41Sopenharmony_ci "textRaw": "`timeout` {number} **Default:** 0 (no timeout)", 2351cb0ef41Sopenharmony_ci "type": "number", 2361cb0ef41Sopenharmony_ci "name": "timeout", 2371cb0ef41Sopenharmony_ci "meta": { 2381cb0ef41Sopenharmony_ci "added": [ 2391cb0ef41Sopenharmony_ci "v0.11.2" 2401cb0ef41Sopenharmony_ci ], 2411cb0ef41Sopenharmony_ci "changes": [ 2421cb0ef41Sopenharmony_ci { 2431cb0ef41Sopenharmony_ci "version": "v13.0.0", 2441cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/27558", 2451cb0ef41Sopenharmony_ci "description": "The default timeout changed from 120s to 0 (no timeout)." 2461cb0ef41Sopenharmony_ci } 2471cb0ef41Sopenharmony_ci ] 2481cb0ef41Sopenharmony_ci }, 2491cb0ef41Sopenharmony_ci "default": "0 (no timeout)", 2501cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#servertimeout\"><code>server.timeout</code></a> in the <code>node:http</code> module.</p>" 2511cb0ef41Sopenharmony_ci }, 2521cb0ef41Sopenharmony_ci { 2531cb0ef41Sopenharmony_ci "textRaw": "`keepAliveTimeout` {number} **Default:** `5000` (5 seconds)", 2541cb0ef41Sopenharmony_ci "type": "number", 2551cb0ef41Sopenharmony_ci "name": "keepAliveTimeout", 2561cb0ef41Sopenharmony_ci "meta": { 2571cb0ef41Sopenharmony_ci "added": [ 2581cb0ef41Sopenharmony_ci "v8.0.0" 2591cb0ef41Sopenharmony_ci ], 2601cb0ef41Sopenharmony_ci "changes": [] 2611cb0ef41Sopenharmony_ci }, 2621cb0ef41Sopenharmony_ci "default": "`5000` (5 seconds)", 2631cb0ef41Sopenharmony_ci "desc": "<p>See <a href=\"http.html#serverkeepalivetimeout\"><code>server.keepAliveTimeout</code></a> in the <code>node:http</code> module.</p>" 2641cb0ef41Sopenharmony_ci } 2651cb0ef41Sopenharmony_ci ] 2661cb0ef41Sopenharmony_ci } 2671cb0ef41Sopenharmony_ci ], 2681cb0ef41Sopenharmony_ci "methods": [ 2691cb0ef41Sopenharmony_ci { 2701cb0ef41Sopenharmony_ci "textRaw": "`https.createServer([options][, requestListener])`", 2711cb0ef41Sopenharmony_ci "type": "method", 2721cb0ef41Sopenharmony_ci "name": "createServer", 2731cb0ef41Sopenharmony_ci "meta": { 2741cb0ef41Sopenharmony_ci "added": [ 2751cb0ef41Sopenharmony_ci "v0.3.4" 2761cb0ef41Sopenharmony_ci ], 2771cb0ef41Sopenharmony_ci "changes": [] 2781cb0ef41Sopenharmony_ci }, 2791cb0ef41Sopenharmony_ci "signatures": [ 2801cb0ef41Sopenharmony_ci { 2811cb0ef41Sopenharmony_ci "return": { 2821cb0ef41Sopenharmony_ci "textRaw": "Returns: {https.Server}", 2831cb0ef41Sopenharmony_ci "name": "return", 2841cb0ef41Sopenharmony_ci "type": "https.Server" 2851cb0ef41Sopenharmony_ci }, 2861cb0ef41Sopenharmony_ci "params": [ 2871cb0ef41Sopenharmony_ci { 2881cb0ef41Sopenharmony_ci "textRaw": "`options` {Object} Accepts `options` from [`tls.createServer()`][], [`tls.createSecureContext()`][] and [`http.createServer()`][].", 2891cb0ef41Sopenharmony_ci "name": "options", 2901cb0ef41Sopenharmony_ci "type": "Object", 2911cb0ef41Sopenharmony_ci "desc": "Accepts `options` from [`tls.createServer()`][], [`tls.createSecureContext()`][] and [`http.createServer()`][]." 2921cb0ef41Sopenharmony_ci }, 2931cb0ef41Sopenharmony_ci { 2941cb0ef41Sopenharmony_ci "textRaw": "`requestListener` {Function} A listener to be added to the `'request'` event.", 2951cb0ef41Sopenharmony_ci "name": "requestListener", 2961cb0ef41Sopenharmony_ci "type": "Function", 2971cb0ef41Sopenharmony_ci "desc": "A listener to be added to the `'request'` event." 2981cb0ef41Sopenharmony_ci } 2991cb0ef41Sopenharmony_ci ] 3001cb0ef41Sopenharmony_ci } 3011cb0ef41Sopenharmony_ci ], 3021cb0ef41Sopenharmony_ci "desc": "<pre><code class=\"language-js\">// curl -k https://localhost:8000/\nconst https = require('node:https');\nconst fs = require('node:fs');\n\nconst options = {\n key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),\n};\n\nhttps.createServer(options, (req, res) => {\n res.writeHead(200);\n res.end('hello world\\n');\n}).listen(8000);\n</code></pre>\n<p>Or</p>\n<pre><code class=\"language-js\">const https = require('node:https');\nconst fs = require('node:fs');\n\nconst options = {\n pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),\n passphrase: 'sample',\n};\n\nhttps.createServer(options, (req, res) => {\n res.writeHead(200);\n res.end('hello world\\n');\n}).listen(8000);\n</code></pre>" 3031cb0ef41Sopenharmony_ci }, 3041cb0ef41Sopenharmony_ci { 3051cb0ef41Sopenharmony_ci "textRaw": "`https.get(options[, callback])`", 3061cb0ef41Sopenharmony_ci "type": "method", 3071cb0ef41Sopenharmony_ci "name": "get", 3081cb0ef41Sopenharmony_ci "meta": { 3091cb0ef41Sopenharmony_ci "added": [ 3101cb0ef41Sopenharmony_ci "v0.3.6" 3111cb0ef41Sopenharmony_ci ], 3121cb0ef41Sopenharmony_ci "changes": [ 3131cb0ef41Sopenharmony_ci { 3141cb0ef41Sopenharmony_ci "version": "v10.9.0", 3151cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/21616", 3161cb0ef41Sopenharmony_ci "description": "The `url` parameter can now be passed along with a separate `options` object." 3171cb0ef41Sopenharmony_ci }, 3181cb0ef41Sopenharmony_ci { 3191cb0ef41Sopenharmony_ci "version": "v7.5.0", 3201cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/10638", 3211cb0ef41Sopenharmony_ci "description": "The `options` parameter can be a WHATWG `URL` object." 3221cb0ef41Sopenharmony_ci } 3231cb0ef41Sopenharmony_ci ] 3241cb0ef41Sopenharmony_ci }, 3251cb0ef41Sopenharmony_ci "signatures": [ 3261cb0ef41Sopenharmony_ci { 3271cb0ef41Sopenharmony_ci "params": [ 3281cb0ef41Sopenharmony_ci { 3291cb0ef41Sopenharmony_ci "textRaw": "`url` {string | URL}", 3301cb0ef41Sopenharmony_ci "name": "url", 3311cb0ef41Sopenharmony_ci "type": "string | URL" 3321cb0ef41Sopenharmony_ci }, 3331cb0ef41Sopenharmony_ci { 3341cb0ef41Sopenharmony_ci "textRaw": "`options` {Object | string | URL} Accepts the same `options` as [`https.request()`][], with the method set to GET by default.", 3351cb0ef41Sopenharmony_ci "name": "options", 3361cb0ef41Sopenharmony_ci "type": "Object | string | URL", 3371cb0ef41Sopenharmony_ci "desc": "Accepts the same `options` as [`https.request()`][], with the method set to GET by default." 3381cb0ef41Sopenharmony_ci }, 3391cb0ef41Sopenharmony_ci { 3401cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 3411cb0ef41Sopenharmony_ci "name": "callback", 3421cb0ef41Sopenharmony_ci "type": "Function" 3431cb0ef41Sopenharmony_ci } 3441cb0ef41Sopenharmony_ci ] 3451cb0ef41Sopenharmony_ci } 3461cb0ef41Sopenharmony_ci ], 3471cb0ef41Sopenharmony_ci "desc": "<p>Like <a href=\"http.html#httpgetoptions-callback\"><code>http.get()</code></a> but for HTTPS.</p>\n<p><code>options</code> can be an object, a string, or a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> object. If <code>options</code> is a\nstring, it is automatically parsed with <a href=\"url.html#new-urlinput-base\"><code>new URL()</code></a>. If it is a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a>\nobject, it will be automatically converted to an ordinary <code>options</code> object.</p>\n<pre><code class=\"language-js\">const https = require('node:https');\n\nhttps.get('https://encrypted.google.com/', (res) => {\n console.log('statusCode:', res.statusCode);\n console.log('headers:', res.headers);\n\n res.on('data', (d) => {\n process.stdout.write(d);\n });\n\n}).on('error', (e) => {\n console.error(e);\n});\n</code></pre>" 3481cb0ef41Sopenharmony_ci }, 3491cb0ef41Sopenharmony_ci { 3501cb0ef41Sopenharmony_ci "textRaw": "`https.get(url[, options][, callback])`", 3511cb0ef41Sopenharmony_ci "type": "method", 3521cb0ef41Sopenharmony_ci "name": "get", 3531cb0ef41Sopenharmony_ci "meta": { 3541cb0ef41Sopenharmony_ci "added": [ 3551cb0ef41Sopenharmony_ci "v0.3.6" 3561cb0ef41Sopenharmony_ci ], 3571cb0ef41Sopenharmony_ci "changes": [ 3581cb0ef41Sopenharmony_ci { 3591cb0ef41Sopenharmony_ci "version": "v10.9.0", 3601cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/21616", 3611cb0ef41Sopenharmony_ci "description": "The `url` parameter can now be passed along with a separate `options` object." 3621cb0ef41Sopenharmony_ci }, 3631cb0ef41Sopenharmony_ci { 3641cb0ef41Sopenharmony_ci "version": "v7.5.0", 3651cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/10638", 3661cb0ef41Sopenharmony_ci "description": "The `options` parameter can be a WHATWG `URL` object." 3671cb0ef41Sopenharmony_ci } 3681cb0ef41Sopenharmony_ci ] 3691cb0ef41Sopenharmony_ci }, 3701cb0ef41Sopenharmony_ci "signatures": [ 3711cb0ef41Sopenharmony_ci { 3721cb0ef41Sopenharmony_ci "params": [ 3731cb0ef41Sopenharmony_ci { 3741cb0ef41Sopenharmony_ci "textRaw": "`url` {string | URL}", 3751cb0ef41Sopenharmony_ci "name": "url", 3761cb0ef41Sopenharmony_ci "type": "string | URL" 3771cb0ef41Sopenharmony_ci }, 3781cb0ef41Sopenharmony_ci { 3791cb0ef41Sopenharmony_ci "textRaw": "`options` {Object | string | URL} Accepts the same `options` as [`https.request()`][], with the method set to GET by default.", 3801cb0ef41Sopenharmony_ci "name": "options", 3811cb0ef41Sopenharmony_ci "type": "Object | string | URL", 3821cb0ef41Sopenharmony_ci "desc": "Accepts the same `options` as [`https.request()`][], with the method set to GET by default." 3831cb0ef41Sopenharmony_ci }, 3841cb0ef41Sopenharmony_ci { 3851cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 3861cb0ef41Sopenharmony_ci "name": "callback", 3871cb0ef41Sopenharmony_ci "type": "Function" 3881cb0ef41Sopenharmony_ci } 3891cb0ef41Sopenharmony_ci ] 3901cb0ef41Sopenharmony_ci } 3911cb0ef41Sopenharmony_ci ], 3921cb0ef41Sopenharmony_ci "desc": "<p>Like <a href=\"http.html#httpgetoptions-callback\"><code>http.get()</code></a> but for HTTPS.</p>\n<p><code>options</code> can be an object, a string, or a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> object. If <code>options</code> is a\nstring, it is automatically parsed with <a href=\"url.html#new-urlinput-base\"><code>new URL()</code></a>. If it is a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a>\nobject, it will be automatically converted to an ordinary <code>options</code> object.</p>\n<pre><code class=\"language-js\">const https = require('node:https');\n\nhttps.get('https://encrypted.google.com/', (res) => {\n console.log('statusCode:', res.statusCode);\n console.log('headers:', res.headers);\n\n res.on('data', (d) => {\n process.stdout.write(d);\n });\n\n}).on('error', (e) => {\n console.error(e);\n});\n</code></pre>" 3931cb0ef41Sopenharmony_ci }, 3941cb0ef41Sopenharmony_ci { 3951cb0ef41Sopenharmony_ci "textRaw": "`https.request(options[, callback])`", 3961cb0ef41Sopenharmony_ci "type": "method", 3971cb0ef41Sopenharmony_ci "name": "request", 3981cb0ef41Sopenharmony_ci "meta": { 3991cb0ef41Sopenharmony_ci "added": [ 4001cb0ef41Sopenharmony_ci "v0.3.6" 4011cb0ef41Sopenharmony_ci ], 4021cb0ef41Sopenharmony_ci "changes": [ 4031cb0ef41Sopenharmony_ci { 4041cb0ef41Sopenharmony_ci "version": [ 4051cb0ef41Sopenharmony_ci "v16.7.0", 4061cb0ef41Sopenharmony_ci "v14.18.0" 4071cb0ef41Sopenharmony_ci ], 4081cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/39310", 4091cb0ef41Sopenharmony_ci "description": "When using a `URL` object parsed username and password will now be properly URI decoded." 4101cb0ef41Sopenharmony_ci }, 4111cb0ef41Sopenharmony_ci { 4121cb0ef41Sopenharmony_ci "version": [ 4131cb0ef41Sopenharmony_ci "v14.1.0", 4141cb0ef41Sopenharmony_ci "v13.14.0" 4151cb0ef41Sopenharmony_ci ], 4161cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/32786", 4171cb0ef41Sopenharmony_ci "description": "The `highWaterMark` option is accepted now." 4181cb0ef41Sopenharmony_ci }, 4191cb0ef41Sopenharmony_ci { 4201cb0ef41Sopenharmony_ci "version": "v10.9.0", 4211cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/21616", 4221cb0ef41Sopenharmony_ci "description": "The `url` parameter can now be passed along with a separate `options` object." 4231cb0ef41Sopenharmony_ci }, 4241cb0ef41Sopenharmony_ci { 4251cb0ef41Sopenharmony_ci "version": "v9.3.0", 4261cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/14903", 4271cb0ef41Sopenharmony_ci "description": "The `options` parameter can now include `clientCertEngine`." 4281cb0ef41Sopenharmony_ci }, 4291cb0ef41Sopenharmony_ci { 4301cb0ef41Sopenharmony_ci "version": "v7.5.0", 4311cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/10638", 4321cb0ef41Sopenharmony_ci "description": "The `options` parameter can be a WHATWG `URL` object." 4331cb0ef41Sopenharmony_ci } 4341cb0ef41Sopenharmony_ci ] 4351cb0ef41Sopenharmony_ci }, 4361cb0ef41Sopenharmony_ci "signatures": [ 4371cb0ef41Sopenharmony_ci { 4381cb0ef41Sopenharmony_ci "return": { 4391cb0ef41Sopenharmony_ci "textRaw": "Returns: {http.ClientRequest}", 4401cb0ef41Sopenharmony_ci "name": "return", 4411cb0ef41Sopenharmony_ci "type": "http.ClientRequest" 4421cb0ef41Sopenharmony_ci }, 4431cb0ef41Sopenharmony_ci "params": [ 4441cb0ef41Sopenharmony_ci { 4451cb0ef41Sopenharmony_ci "textRaw": "`url` {string | URL}", 4461cb0ef41Sopenharmony_ci "name": "url", 4471cb0ef41Sopenharmony_ci "type": "string | URL" 4481cb0ef41Sopenharmony_ci }, 4491cb0ef41Sopenharmony_ci { 4501cb0ef41Sopenharmony_ci "textRaw": "`options` {Object | string | URL} Accepts all `options` from [`http.request()`][], with some differences in default values:", 4511cb0ef41Sopenharmony_ci "name": "options", 4521cb0ef41Sopenharmony_ci "type": "Object | string | URL", 4531cb0ef41Sopenharmony_ci "desc": "Accepts all `options` from [`http.request()`][], with some differences in default values:", 4541cb0ef41Sopenharmony_ci "options": [ 4551cb0ef41Sopenharmony_ci { 4561cb0ef41Sopenharmony_ci "textRaw": "`protocol` **Default:** `'https:'`", 4571cb0ef41Sopenharmony_ci "name": "protocol", 4581cb0ef41Sopenharmony_ci "default": "`'https:'`" 4591cb0ef41Sopenharmony_ci }, 4601cb0ef41Sopenharmony_ci { 4611cb0ef41Sopenharmony_ci "textRaw": "`port` **Default:** `443`", 4621cb0ef41Sopenharmony_ci "name": "port", 4631cb0ef41Sopenharmony_ci "default": "`443`" 4641cb0ef41Sopenharmony_ci }, 4651cb0ef41Sopenharmony_ci { 4661cb0ef41Sopenharmony_ci "textRaw": "`agent` **Default:** `https.globalAgent`", 4671cb0ef41Sopenharmony_ci "name": "agent", 4681cb0ef41Sopenharmony_ci "default": "`https.globalAgent`" 4691cb0ef41Sopenharmony_ci } 4701cb0ef41Sopenharmony_ci ] 4711cb0ef41Sopenharmony_ci }, 4721cb0ef41Sopenharmony_ci { 4731cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 4741cb0ef41Sopenharmony_ci "name": "callback", 4751cb0ef41Sopenharmony_ci "type": "Function" 4761cb0ef41Sopenharmony_ci } 4771cb0ef41Sopenharmony_ci ] 4781cb0ef41Sopenharmony_ci } 4791cb0ef41Sopenharmony_ci ], 4801cb0ef41Sopenharmony_ci "desc": "<p>Makes a request to a secure web server.</p>\n<p>The following additional <code>options</code> from <a href=\"tls.html#tlsconnectoptions-callback\"><code>tls.connect()</code></a> are also accepted:\n<code>ca</code>, <code>cert</code>, <code>ciphers</code>, <code>clientCertEngine</code>, <code>crl</code>, <code>dhparam</code>, <code>ecdhCurve</code>,\n<code>honorCipherOrder</code>, <code>key</code>, <code>passphrase</code>, <code>pfx</code>, <code>rejectUnauthorized</code>,\n<code>secureOptions</code>, <code>secureProtocol</code>, <code>servername</code>, <code>sessionIdContext</code>,\n<code>highWaterMark</code>.</p>\n<p><code>options</code> can be an object, a string, or a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> object. If <code>options</code> is a\nstring, it is automatically parsed with <a href=\"url.html#new-urlinput-base\"><code>new URL()</code></a>. If it is a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a>\nobject, it will be automatically converted to an ordinary <code>options</code> object.</p>\n<p><code>https.request()</code> returns an instance of the <a href=\"http.html#class-httpclientrequest\"><code>http.ClientRequest</code></a>\nclass. The <code>ClientRequest</code> instance is a writable stream. If one needs to\nupload a file with a POST request, then write to the <code>ClientRequest</code> object.</p>\n<pre><code class=\"language-js\">const https = require('node:https');\n\nconst options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n};\n\nconst req = https.request(options, (res) => {\n console.log('statusCode:', res.statusCode);\n console.log('headers:', res.headers);\n\n res.on('data', (d) => {\n process.stdout.write(d);\n });\n});\n\nreq.on('error', (e) => {\n console.error(e);\n});\nreq.end();\n</code></pre>\n<p>Example using options from <a href=\"tls.html#tlsconnectoptions-callback\"><code>tls.connect()</code></a>:</p>\n<pre><code class=\"language-js\">const options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),\n};\noptions.agent = new https.Agent(options);\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Alternatively, opt out of connection pooling by not using an <a href=\"#class-httpsagent\"><code>Agent</code></a>.</p>\n<pre><code class=\"language-js\">const options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),\n agent: false,\n};\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Example using a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> as <code>options</code>:</p>\n<pre><code class=\"language-js\">const options = new URL('https://abc:xyz@example.com');\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Example pinning on certificate fingerprint, or the public key (similar to\n<code>pin-sha256</code>):</p>\n<pre><code class=\"language-js\">const tls = require('node:tls');\nconst https = require('node:https');\nconst crypto = require('node:crypto');\n\nfunction sha256(s) {\n return crypto.createHash('sha256').update(s).digest('base64');\n}\nconst options = {\n hostname: 'github.com',\n port: 443,\n path: '/',\n method: 'GET',\n checkServerIdentity: function(host, cert) {\n // Make sure the certificate is issued to the host we are connected to\n const err = tls.checkServerIdentity(host, cert);\n if (err) {\n return err;\n }\n\n // Pin the public key, similar to HPKP pin-sha256 pinning\n const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';\n if (sha256(cert.pubkey) !== pubkey256) {\n const msg = 'Certificate verification error: ' +\n `The public key of '${cert.subject.CN}' ` +\n 'does not match our pinned fingerprint';\n return new Error(msg);\n }\n\n // Pin the exact certificate, rather than the pub key\n const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +\n 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';\n if (cert.fingerprint256 !== cert256) {\n const msg = 'Certificate verification error: ' +\n `The certificate of '${cert.subject.CN}' ` +\n 'does not match our pinned fingerprint';\n return new Error(msg);\n }\n\n // This loop is informational only.\n // Print the certificate and public key fingerprints of all certs in the\n // chain. Its common to pin the public key of the issuer on the public\n // internet, while pinning the public key of the service in sensitive\n // environments.\n do {\n console.log('Subject Common Name:', cert.subject.CN);\n console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);\n\n hash = crypto.createHash('sha256');\n console.log(' Public key ping-sha256:', sha256(cert.pubkey));\n\n lastprint256 = cert.fingerprint256;\n cert = cert.issuerCertificate;\n } while (cert.fingerprint256 !== lastprint256);\n\n },\n};\n\noptions.agent = new https.Agent(options);\nconst req = https.request(options, (res) => {\n console.log('All OK. Server matched our pinned cert or public key');\n console.log('statusCode:', res.statusCode);\n // Print the HPKP values\n console.log('headers:', res.headers['public-key-pins']);\n\n res.on('data', (d) => {});\n});\n\nreq.on('error', (e) => {\n console.error(e.message);\n});\nreq.end();\n</code></pre>\n<p>Outputs for example:</p>\n<pre><code class=\"language-text\">Subject Common Name: github.com\n Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16\n Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=\nSubject Common Name: DigiCert SHA2 Extended Validation Server CA\n Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A\n Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=\nSubject Common Name: DigiCert High Assurance EV Root CA\n Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF\n Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=\nAll OK. Server matched our pinned cert or public key\nstatusCode: 200\nheaders: max-age=0; pin-sha256=\"WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=\"; pin-sha256=\"RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=\"; pin-sha256=\"k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws=\"; pin-sha256=\"K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q=\"; pin-sha256=\"IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=\"; pin-sha256=\"iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=\"; pin-sha256=\"LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A=\"; includeSubDomains\n</code></pre>" 4811cb0ef41Sopenharmony_ci }, 4821cb0ef41Sopenharmony_ci { 4831cb0ef41Sopenharmony_ci "textRaw": "`https.request(url[, options][, callback])`", 4841cb0ef41Sopenharmony_ci "type": "method", 4851cb0ef41Sopenharmony_ci "name": "request", 4861cb0ef41Sopenharmony_ci "meta": { 4871cb0ef41Sopenharmony_ci "added": [ 4881cb0ef41Sopenharmony_ci "v0.3.6" 4891cb0ef41Sopenharmony_ci ], 4901cb0ef41Sopenharmony_ci "changes": [ 4911cb0ef41Sopenharmony_ci { 4921cb0ef41Sopenharmony_ci "version": [ 4931cb0ef41Sopenharmony_ci "v16.7.0", 4941cb0ef41Sopenharmony_ci "v14.18.0" 4951cb0ef41Sopenharmony_ci ], 4961cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/39310", 4971cb0ef41Sopenharmony_ci "description": "When using a `URL` object parsed username and password will now be properly URI decoded." 4981cb0ef41Sopenharmony_ci }, 4991cb0ef41Sopenharmony_ci { 5001cb0ef41Sopenharmony_ci "version": [ 5011cb0ef41Sopenharmony_ci "v14.1.0", 5021cb0ef41Sopenharmony_ci "v13.14.0" 5031cb0ef41Sopenharmony_ci ], 5041cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/32786", 5051cb0ef41Sopenharmony_ci "description": "The `highWaterMark` option is accepted now." 5061cb0ef41Sopenharmony_ci }, 5071cb0ef41Sopenharmony_ci { 5081cb0ef41Sopenharmony_ci "version": "v10.9.0", 5091cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/21616", 5101cb0ef41Sopenharmony_ci "description": "The `url` parameter can now be passed along with a separate `options` object." 5111cb0ef41Sopenharmony_ci }, 5121cb0ef41Sopenharmony_ci { 5131cb0ef41Sopenharmony_ci "version": "v9.3.0", 5141cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/14903", 5151cb0ef41Sopenharmony_ci "description": "The `options` parameter can now include `clientCertEngine`." 5161cb0ef41Sopenharmony_ci }, 5171cb0ef41Sopenharmony_ci { 5181cb0ef41Sopenharmony_ci "version": "v7.5.0", 5191cb0ef41Sopenharmony_ci "pr-url": "https://github.com/nodejs/node/pull/10638", 5201cb0ef41Sopenharmony_ci "description": "The `options` parameter can be a WHATWG `URL` object." 5211cb0ef41Sopenharmony_ci } 5221cb0ef41Sopenharmony_ci ] 5231cb0ef41Sopenharmony_ci }, 5241cb0ef41Sopenharmony_ci "signatures": [ 5251cb0ef41Sopenharmony_ci { 5261cb0ef41Sopenharmony_ci "return": { 5271cb0ef41Sopenharmony_ci "textRaw": "Returns: {http.ClientRequest}", 5281cb0ef41Sopenharmony_ci "name": "return", 5291cb0ef41Sopenharmony_ci "type": "http.ClientRequest" 5301cb0ef41Sopenharmony_ci }, 5311cb0ef41Sopenharmony_ci "params": [ 5321cb0ef41Sopenharmony_ci { 5331cb0ef41Sopenharmony_ci "textRaw": "`url` {string | URL}", 5341cb0ef41Sopenharmony_ci "name": "url", 5351cb0ef41Sopenharmony_ci "type": "string | URL" 5361cb0ef41Sopenharmony_ci }, 5371cb0ef41Sopenharmony_ci { 5381cb0ef41Sopenharmony_ci "textRaw": "`options` {Object | string | URL} Accepts all `options` from [`http.request()`][], with some differences in default values:", 5391cb0ef41Sopenharmony_ci "name": "options", 5401cb0ef41Sopenharmony_ci "type": "Object | string | URL", 5411cb0ef41Sopenharmony_ci "desc": "Accepts all `options` from [`http.request()`][], with some differences in default values:", 5421cb0ef41Sopenharmony_ci "options": [ 5431cb0ef41Sopenharmony_ci { 5441cb0ef41Sopenharmony_ci "textRaw": "`protocol` **Default:** `'https:'`", 5451cb0ef41Sopenharmony_ci "name": "protocol", 5461cb0ef41Sopenharmony_ci "default": "`'https:'`" 5471cb0ef41Sopenharmony_ci }, 5481cb0ef41Sopenharmony_ci { 5491cb0ef41Sopenharmony_ci "textRaw": "`port` **Default:** `443`", 5501cb0ef41Sopenharmony_ci "name": "port", 5511cb0ef41Sopenharmony_ci "default": "`443`" 5521cb0ef41Sopenharmony_ci }, 5531cb0ef41Sopenharmony_ci { 5541cb0ef41Sopenharmony_ci "textRaw": "`agent` **Default:** `https.globalAgent`", 5551cb0ef41Sopenharmony_ci "name": "agent", 5561cb0ef41Sopenharmony_ci "default": "`https.globalAgent`" 5571cb0ef41Sopenharmony_ci } 5581cb0ef41Sopenharmony_ci ] 5591cb0ef41Sopenharmony_ci }, 5601cb0ef41Sopenharmony_ci { 5611cb0ef41Sopenharmony_ci "textRaw": "`callback` {Function}", 5621cb0ef41Sopenharmony_ci "name": "callback", 5631cb0ef41Sopenharmony_ci "type": "Function" 5641cb0ef41Sopenharmony_ci } 5651cb0ef41Sopenharmony_ci ] 5661cb0ef41Sopenharmony_ci } 5671cb0ef41Sopenharmony_ci ], 5681cb0ef41Sopenharmony_ci "desc": "<p>Makes a request to a secure web server.</p>\n<p>The following additional <code>options</code> from <a href=\"tls.html#tlsconnectoptions-callback\"><code>tls.connect()</code></a> are also accepted:\n<code>ca</code>, <code>cert</code>, <code>ciphers</code>, <code>clientCertEngine</code>, <code>crl</code>, <code>dhparam</code>, <code>ecdhCurve</code>,\n<code>honorCipherOrder</code>, <code>key</code>, <code>passphrase</code>, <code>pfx</code>, <code>rejectUnauthorized</code>,\n<code>secureOptions</code>, <code>secureProtocol</code>, <code>servername</code>, <code>sessionIdContext</code>,\n<code>highWaterMark</code>.</p>\n<p><code>options</code> can be an object, a string, or a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> object. If <code>options</code> is a\nstring, it is automatically parsed with <a href=\"url.html#new-urlinput-base\"><code>new URL()</code></a>. If it is a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a>\nobject, it will be automatically converted to an ordinary <code>options</code> object.</p>\n<p><code>https.request()</code> returns an instance of the <a href=\"http.html#class-httpclientrequest\"><code>http.ClientRequest</code></a>\nclass. The <code>ClientRequest</code> instance is a writable stream. If one needs to\nupload a file with a POST request, then write to the <code>ClientRequest</code> object.</p>\n<pre><code class=\"language-js\">const https = require('node:https');\n\nconst options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n};\n\nconst req = https.request(options, (res) => {\n console.log('statusCode:', res.statusCode);\n console.log('headers:', res.headers);\n\n res.on('data', (d) => {\n process.stdout.write(d);\n });\n});\n\nreq.on('error', (e) => {\n console.error(e);\n});\nreq.end();\n</code></pre>\n<p>Example using options from <a href=\"tls.html#tlsconnectoptions-callback\"><code>tls.connect()</code></a>:</p>\n<pre><code class=\"language-js\">const options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),\n};\noptions.agent = new https.Agent(options);\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Alternatively, opt out of connection pooling by not using an <a href=\"#class-httpsagent\"><code>Agent</code></a>.</p>\n<pre><code class=\"language-js\">const options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET',\n key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),\n cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),\n agent: false,\n};\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Example using a <a href=\"url.html#the-whatwg-url-api\"><code>URL</code></a> as <code>options</code>:</p>\n<pre><code class=\"language-js\">const options = new URL('https://abc:xyz@example.com');\n\nconst req = https.request(options, (res) => {\n // ...\n});\n</code></pre>\n<p>Example pinning on certificate fingerprint, or the public key (similar to\n<code>pin-sha256</code>):</p>\n<pre><code class=\"language-js\">const tls = require('node:tls');\nconst https = require('node:https');\nconst crypto = require('node:crypto');\n\nfunction sha256(s) {\n return crypto.createHash('sha256').update(s).digest('base64');\n}\nconst options = {\n hostname: 'github.com',\n port: 443,\n path: '/',\n method: 'GET',\n checkServerIdentity: function(host, cert) {\n // Make sure the certificate is issued to the host we are connected to\n const err = tls.checkServerIdentity(host, cert);\n if (err) {\n return err;\n }\n\n // Pin the public key, similar to HPKP pin-sha256 pinning\n const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';\n if (sha256(cert.pubkey) !== pubkey256) {\n const msg = 'Certificate verification error: ' +\n `The public key of '${cert.subject.CN}' ` +\n 'does not match our pinned fingerprint';\n return new Error(msg);\n }\n\n // Pin the exact certificate, rather than the pub key\n const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +\n 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';\n if (cert.fingerprint256 !== cert256) {\n const msg = 'Certificate verification error: ' +\n `The certificate of '${cert.subject.CN}' ` +\n 'does not match our pinned fingerprint';\n return new Error(msg);\n }\n\n // This loop is informational only.\n // Print the certificate and public key fingerprints of all certs in the\n // chain. Its common to pin the public key of the issuer on the public\n // internet, while pinning the public key of the service in sensitive\n // environments.\n do {\n console.log('Subject Common Name:', cert.subject.CN);\n console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);\n\n hash = crypto.createHash('sha256');\n console.log(' Public key ping-sha256:', sha256(cert.pubkey));\n\n lastprint256 = cert.fingerprint256;\n cert = cert.issuerCertificate;\n } while (cert.fingerprint256 !== lastprint256);\n\n },\n};\n\noptions.agent = new https.Agent(options);\nconst req = https.request(options, (res) => {\n console.log('All OK. Server matched our pinned cert or public key');\n console.log('statusCode:', res.statusCode);\n // Print the HPKP values\n console.log('headers:', res.headers['public-key-pins']);\n\n res.on('data', (d) => {});\n});\n\nreq.on('error', (e) => {\n console.error(e.message);\n});\nreq.end();\n</code></pre>\n<p>Outputs for example:</p>\n<pre><code class=\"language-text\">Subject Common Name: github.com\n Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16\n Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=\nSubject Common Name: DigiCert SHA2 Extended Validation Server CA\n Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A\n Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=\nSubject Common Name: DigiCert High Assurance EV Root CA\n Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF\n Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=\nAll OK. Server matched our pinned cert or public key\nstatusCode: 200\nheaders: max-age=0; pin-sha256=\"WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=\"; pin-sha256=\"RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=\"; pin-sha256=\"k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws=\"; pin-sha256=\"K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q=\"; pin-sha256=\"IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=\"; pin-sha256=\"iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=\"; pin-sha256=\"LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A=\"; includeSubDomains\n</code></pre>" 5691cb0ef41Sopenharmony_ci } 5701cb0ef41Sopenharmony_ci ], 5711cb0ef41Sopenharmony_ci "properties": [ 5721cb0ef41Sopenharmony_ci { 5731cb0ef41Sopenharmony_ci "textRaw": "`https.globalAgent`", 5741cb0ef41Sopenharmony_ci "name": "globalAgent", 5751cb0ef41Sopenharmony_ci "meta": { 5761cb0ef41Sopenharmony_ci "added": [ 5771cb0ef41Sopenharmony_ci "v0.5.9" 5781cb0ef41Sopenharmony_ci ], 5791cb0ef41Sopenharmony_ci "changes": [] 5801cb0ef41Sopenharmony_ci }, 5811cb0ef41Sopenharmony_ci "desc": "<p>Global instance of <a href=\"#class-httpsagent\"><code>https.Agent</code></a> for all HTTPS client requests.</p>" 5821cb0ef41Sopenharmony_ci } 5831cb0ef41Sopenharmony_ci ], 5841cb0ef41Sopenharmony_ci "type": "module", 5851cb0ef41Sopenharmony_ci "displayName": "HTTPS" 5861cb0ef41Sopenharmony_ci } 5871cb0ef41Sopenharmony_ci ] 5881cb0ef41Sopenharmony_ci}