HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a\nseparate module.\n\n
\n", "classes": [ { "textRaw": "Class: https.Agent", "type": "class", "name": "https.Agent", "desc": "An Agent object for HTTPS similar to [http.Agent][]. See [https.request()][]\nfor more information.\n\n
This class is a subclass of tls.Server and emits events same as\n[http.Server][]. See [http.Server][] for more information.\n\n
See [http.Server#setTimeout()][].\n\n
See [http.Server#timeout][].\n\n
Returns a new HTTPS web server object. The options is similar to\n[tls.createServer()][]. The requestListener is a function which is\nautomatically added to the 'request' event.\n\n
Example:\n\n
\n// curl -k https://localhost:8000/\nconst https = require('https');\nconst fs = require('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);\nOr\n\n
\nconst https = require('https');\nconst fs = require('fs');\n\nconst options = {\n pfx: fs.readFileSync('server.pfx')\n};\n\nhttps.createServer(options, (req, res) => {\n res.writeHead(200);\n res.end('hello world\\n');\n}).listen(8000);\n",
"methods": [
{
"textRaw": "server.close([callback])",
"type": "method",
"name": "close",
"desc": "See [http.close()][] for details.\n\n
See [http.listen()][] for details.\n\n
See [http.listen()][] for details.\n\n
Like [http.get()][] but for HTTPS.\n\n
options can be an object or a string. If options is a string, it is\nautomatically parsed with [url.parse()][].\n\n
Example:\n\n
\nconst https = require('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",
"signatures": [
{
"params": [
{
"name": "options"
},
{
"name": "callback"
}
]
}
]
},
{
"textRaw": "https.request(options, callback)",
"type": "method",
"name": "request",
"desc": "Makes a request to a secure web server.\n\n
\noptions can be an object or a string. If options is a string, it is\nautomatically parsed with [url.parse()][].\n\n
All options from [http.request()][] are valid.\n\n
Example:\n\n
\nconst https = require('https');\n\nvar options = {\n hostname: 'encrypted.google.com',\n port: 443,\n path: '/',\n method: 'GET'\n};\n\nvar 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});\nreq.end();\n\nreq.on('error', (e) => {\n console.error(e);\n});\nThe options argument has the following options\n\n
\nhost: A domain name or IP address of the server to issue the request to.\nDefaults to 'localhost'.hostname: Alias for host. To support url.parse() hostname is\npreferred over host.family: IP address family to use when resolving host and hostname.\nValid values are 4 or 6. When unspecified, both IP v4 and v6 will be\nused.port: Port of remote server. Defaults to 443.localAddress: Local interface to bind for network connections.socketPath: Unix Domain Socket (use one of host:port or socketPath).method: A string specifying the HTTP request method. Defaults to 'GET'.path: Request path. Defaults to '/'. Should include query string if any.\nE.G. '/index.html?page=12'. An exception is thrown when the request path\ncontains illegal characters. Currently, only spaces are rejected but that\nmay change in the future.headers: An object containing request headers.auth: Basic authentication i.e. 'user:password' to compute an\nAuthorization header.agent: Controls [Agent][] behavior. When an Agent is used request will\ndefault to Connection: keep-alive. Possible values:undefined (default): use [globalAgent][] for this host and port.Agent object: explicitly use the passed in Agent.false: opts out of connection pooling with an Agent, defaults request to\nConnection: close.The following options from [tls.connect()][] can also be specified. However, a\n[globalAgent][] silently ignores these.\n\n
pfx: Certificate, Private key and CA certificates to use for SSL. Default null.key: Private key to use for SSL. Default null.passphrase: A string of passphrase for the private key or pfx. Default null.cert: Public x509 certificate to use. Default null.ca: A string, [Buffer][] or array of strings or [Buffer][]s of trusted\ncertificates in PEM format. If this is omitted several well known "root"\nCAs will be used, like VeriSign. These are used to authorize connections.ciphers: A string describing the ciphers to use or exclude. Consult\nhttps://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT for\ndetails on the format.rejectUnauthorized: If true, the server certificate is verified against\nthe list of supplied CAs. An 'error' event is emitted if verification\nfails. Verification happens at the connection level, before the HTTP\nrequest is sent. Default true.secureProtocol: The SSL method to use, e.g. SSLv3_method to force\nSSL version 3. The possible values depend on your installation of\nOpenSSL and are defined in the constant [SSL_METHODS][].servername: Servername for SNI (Server Name Indication) TLS extension.In order to specify these options, use a custom [Agent][].\n\n
Example:\n\n
\nvar 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\nvar req = https.request(options, (res) => {\n ...\n}\nAlternatively, opt out of connection pooling by not using an Agent.\n\n
Example:\n\n
\nvar 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\nvar req = https.request(options, (res) => {\n ...\n}\n",
"signatures": [
{
"params": [
{
"name": "options"
},
{
"name": "callback"
}
]
}
]
}
],
"properties": [
{
"textRaw": "https.globalAgent",
"name": "globalAgent",
"desc": "Global instance of [https.Agent][] for all HTTPS client requests.\n\n