2017-01-03 13:16:48 -08:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2014-11-22 16:59:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
2019-11-22 18:04:46 +01:00
|
|
|
const {
|
2020-11-17 13:10:49 +01:00
|
|
|
ArrayPrototypeIndexOf,
|
|
|
|
ArrayPrototypePush,
|
|
|
|
ArrayPrototypeShift,
|
|
|
|
ArrayPrototypeSplice,
|
|
|
|
ArrayPrototypeUnshift,
|
|
|
|
FunctionPrototypeCall,
|
|
|
|
JSONStringify,
|
2019-11-22 18:04:46 +01:00
|
|
|
ObjectAssign,
|
|
|
|
ObjectSetPrototypeOf,
|
2023-06-12 10:47:25 +03:00
|
|
|
ReflectApply,
|
2020-11-17 13:10:49 +01:00
|
|
|
ReflectConstruct,
|
2024-10-07 11:47:44 +02:00
|
|
|
SymbolAsyncDispose,
|
2019-11-22 18:04:46 +01:00
|
|
|
} = primordials;
|
2019-04-09 09:55:53 +02:00
|
|
|
|
2022-05-21 17:53:17 +08:00
|
|
|
const {
|
|
|
|
assertCrypto,
|
|
|
|
kEmptyObject,
|
2023-06-25 23:29:58 +03:00
|
|
|
promisify,
|
2022-05-21 17:53:17 +08:00
|
|
|
} = require('internal/util');
|
|
|
|
assertCrypto();
|
2016-03-08 15:31:31 -08:00
|
|
|
|
2015-01-21 11:36:59 -05:00
|
|
|
const tls = require('tls');
|
2017-10-22 17:23:43 -07:00
|
|
|
const { Agent: HttpAgent } = require('_http_agent');
|
|
|
|
const {
|
2023-06-12 10:47:25 +03:00
|
|
|
httpServerPreClose,
|
2017-10-22 17:23:43 -07:00
|
|
|
Server: HttpServer,
|
2022-04-13 16:47:59 +02:00
|
|
|
setupConnectionsTracking,
|
2021-06-17 22:29:03 +08:00
|
|
|
storeHTTPOptions,
|
2018-05-31 14:26:31 -07:00
|
|
|
_connectionListener,
|
2017-10-22 17:23:43 -07:00
|
|
|
} = require('_http_server');
|
|
|
|
const { ClientRequest } = require('_http_client');
|
2020-03-14 07:55:44 -04:00
|
|
|
let debug = require('internal/util/debuglog').debuglog('https', (fn) => {
|
|
|
|
debug = fn;
|
|
|
|
});
|
2023-02-27 09:31:18 -05:00
|
|
|
const { URL, urlToHttpOptions, isURL } = require('internal/url');
|
2023-01-25 17:52:33 +09:00
|
|
|
const { validateObject } = require('internal/validators');
|
2011-01-02 01:13:56 -08:00
|
|
|
|
|
|
|
function Server(opts, requestListener) {
|
|
|
|
if (!(this instanceof Server)) return new Server(opts, requestListener);
|
2011-04-14 10:53:39 +07:00
|
|
|
|
2024-08-31 23:04:10 -04:00
|
|
|
let ALPNProtocols = ['http/1.1'];
|
2017-06-10 14:09:35 -04:00
|
|
|
if (typeof opts === 'function') {
|
|
|
|
requestListener = opts;
|
2023-01-25 17:52:33 +09:00
|
|
|
opts = kEmptyObject;
|
|
|
|
} else if (opts == null) {
|
|
|
|
opts = kEmptyObject;
|
|
|
|
} else {
|
|
|
|
validateObject(opts, 'options');
|
2024-08-31 23:04:10 -04:00
|
|
|
// Only one of ALPNProtocols and ALPNCallback can be set, so make sure we
|
|
|
|
// only set a default ALPNProtocols if the caller has not set either of them
|
|
|
|
if (opts.ALPNProtocols || opts.ALPNCallback)
|
|
|
|
ALPNProtocols = undefined;
|
2015-04-23 15:25:15 +09:00
|
|
|
}
|
|
|
|
|
2021-06-17 22:29:03 +08:00
|
|
|
FunctionPrototypeCall(storeHTTPOptions, this, opts);
|
2023-01-25 17:52:33 +09:00
|
|
|
FunctionPrototypeCall(tls.Server, this,
|
|
|
|
{
|
|
|
|
noDelay: true,
|
2024-08-31 23:04:10 -04:00
|
|
|
ALPNProtocols,
|
2023-01-25 17:52:33 +09:00
|
|
|
...opts,
|
|
|
|
},
|
|
|
|
_connectionListener);
|
2011-01-02 01:13:56 -08:00
|
|
|
|
2011-02-07 21:11:43 -08:00
|
|
|
this.httpAllowHalfOpen = false;
|
|
|
|
|
2011-01-02 01:13:56 -08:00
|
|
|
if (requestListener) {
|
|
|
|
this.addListener('request', requestListener);
|
|
|
|
}
|
2012-10-08 01:22:44 +02:00
|
|
|
|
2016-10-21 03:21:47 +00:00
|
|
|
this.addListener('tlsClientError', function addListener(err, conn) {
|
2016-01-06 17:00:27 -05:00
|
|
|
if (!this.emit('clientError', err, conn))
|
|
|
|
conn.destroy(err);
|
2012-10-08 01:22:44 +02:00
|
|
|
});
|
2013-04-30 12:43:32 +02:00
|
|
|
|
2019-05-03 16:45:57 -07:00
|
|
|
this.timeout = 0;
|
2018-04-23 03:48:41 +09:00
|
|
|
this.maxHeadersCount = null;
|
2023-07-24 22:55:19 +02:00
|
|
|
this.on('listening', setupConnectionsTracking);
|
2011-01-02 01:13:56 -08:00
|
|
|
}
|
2023-07-24 22:55:19 +02:00
|
|
|
|
2019-11-22 18:04:46 +01:00
|
|
|
ObjectSetPrototypeOf(Server.prototype, tls.Server.prototype);
|
|
|
|
ObjectSetPrototypeOf(Server, tls.Server);
|
2011-01-02 01:13:56 -08:00
|
|
|
|
2022-04-28 12:05:55 +02:00
|
|
|
Server.prototype.closeAllConnections = HttpServer.prototype.closeAllConnections;
|
|
|
|
|
|
|
|
Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnections;
|
|
|
|
|
2017-10-22 17:23:43 -07:00
|
|
|
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
|
2011-01-02 01:13:56 -08:00
|
|
|
|
2025-05-12 21:28:05 +09:00
|
|
|
Server.prototype.close = function close() {
|
2023-06-12 10:47:25 +03:00
|
|
|
httpServerPreClose(this);
|
|
|
|
ReflectApply(tls.Server.prototype.close, this, arguments);
|
2024-02-27 00:07:39 +08:00
|
|
|
return this;
|
2023-06-12 10:47:25 +03:00
|
|
|
};
|
|
|
|
|
2023-06-25 23:29:58 +03:00
|
|
|
Server.prototype[SymbolAsyncDispose] = async function() {
|
2025-05-25 21:44:43 +08:00
|
|
|
await FunctionPrototypeCall(promisify(this.close), this);
|
2023-06-25 23:29:58 +03:00
|
|
|
};
|
|
|
|
|
2021-05-08 04:57:48 +04:30
|
|
|
/**
|
|
|
|
* Creates a new `https.Server` instance.
|
|
|
|
* @param {{
|
|
|
|
* IncomingMessage?: IncomingMessage;
|
|
|
|
* ServerResponse?: ServerResponse;
|
|
|
|
* insecureHTTPParser?: boolean;
|
|
|
|
* maxHeaderSize?: number;
|
|
|
|
* }} [opts]
|
|
|
|
* @param {Function} [requestListener]
|
|
|
|
* @returns {Server}
|
|
|
|
*/
|
2017-10-22 17:23:43 -07:00
|
|
|
function createServer(opts, requestListener) {
|
2011-01-02 01:13:56 -08:00
|
|
|
return new Server(opts, requestListener);
|
2017-10-22 17:23:43 -07:00
|
|
|
}
|
2011-01-21 13:12:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
// HTTPS agents.
|
2011-10-04 20:51:34 +02:00
|
|
|
|
2012-12-28 12:40:06 +09:00
|
|
|
function createConnection(port, host, options) {
|
2015-01-28 20:05:53 -05:00
|
|
|
if (port !== null && typeof port === 'object') {
|
2012-12-28 12:40:06 +09:00
|
|
|
options = port;
|
2015-01-28 20:05:53 -05:00
|
|
|
} else if (host !== null && typeof host === 'object') {
|
2020-01-02 08:42:19 +05:30
|
|
|
options = { ...host };
|
2015-02-07 12:40:05 +01:00
|
|
|
} else if (options === null || typeof options !== 'object') {
|
2012-12-28 12:40:06 +09:00
|
|
|
options = {};
|
2020-01-02 08:42:19 +05:30
|
|
|
} else {
|
|
|
|
options = { ...options };
|
2012-02-23 17:37:49 +02:00
|
|
|
}
|
2012-12-28 12:40:06 +09:00
|
|
|
|
2015-01-28 20:05:53 -05:00
|
|
|
if (typeof port === 'number') {
|
2012-12-28 12:40:06 +09:00
|
|
|
options.port = port;
|
|
|
|
}
|
|
|
|
|
2015-01-28 20:05:53 -05:00
|
|
|
if (typeof host === 'string') {
|
2012-12-28 12:40:06 +09:00
|
|
|
options.host = host;
|
|
|
|
}
|
|
|
|
|
2013-05-22 18:44:24 -07:00
|
|
|
debug('createConnection', options);
|
2015-07-22 21:18:38 -07:00
|
|
|
|
|
|
|
if (options._agentKey) {
|
|
|
|
const session = this._getSession(options._agentKey);
|
|
|
|
if (session) {
|
|
|
|
debug('reuse session for %j', options._agentKey);
|
2018-12-18 03:15:57 +01:00
|
|
|
options = {
|
|
|
|
session,
|
2023-02-12 19:26:21 +01:00
|
|
|
...options,
|
2018-12-18 03:15:57 +01:00
|
|
|
};
|
2015-07-22 21:18:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-30 12:18:04 -08:00
|
|
|
const socket = tls.connect(options);
|
2015-07-22 21:18:38 -07:00
|
|
|
|
2019-01-30 12:18:04 -08:00
|
|
|
if (options._agentKey) {
|
|
|
|
// Cache new session for reuse
|
|
|
|
socket.on('session', (session) => {
|
|
|
|
this._cacheSession(options._agentKey, session);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Evict session on error
|
|
|
|
socket.once('close', (err) => {
|
|
|
|
if (err)
|
|
|
|
this._evictSession(options._agentKey);
|
|
|
|
});
|
|
|
|
}
|
2016-01-30 18:49:11 -05:00
|
|
|
|
2015-07-22 21:18:38 -07:00
|
|
|
return socket;
|
2012-02-18 15:01:35 -08:00
|
|
|
}
|
2011-01-21 13:12:35 -08:00
|
|
|
|
2021-05-08 04:57:48 +04:30
|
|
|
/**
|
|
|
|
* Creates a new `HttpAgent` instance.
|
|
|
|
* @param {{
|
|
|
|
* keepAlive?: boolean;
|
|
|
|
* keepAliveMsecs?: number;
|
|
|
|
* maxSockets?: number;
|
|
|
|
* maxTotalSockets?: number;
|
|
|
|
* maxFreeSockets?: number;
|
|
|
|
* scheduling?: string;
|
|
|
|
* timeout?: number;
|
|
|
|
* maxCachedSessions?: number;
|
|
|
|
* servername?: string;
|
|
|
|
* }} [options]
|
2022-10-30 09:03:10 -07:00
|
|
|
* @constructor
|
2021-05-08 04:57:48 +04:30
|
|
|
*/
|
2011-01-21 13:12:35 -08:00
|
|
|
function Agent(options) {
|
2017-05-09 14:32:34 -04:00
|
|
|
if (!(this instanceof Agent))
|
|
|
|
return new Agent(options);
|
|
|
|
|
2020-11-17 13:10:49 +01:00
|
|
|
FunctionPrototypeCall(HttpAgent, this, options);
|
2013-05-22 18:44:24 -07:00
|
|
|
this.defaultPort = 443;
|
|
|
|
this.protocol = 'https:';
|
2015-07-22 21:18:38 -07:00
|
|
|
this.maxCachedSessions = this.options.maxCachedSessions;
|
|
|
|
if (this.maxCachedSessions === undefined)
|
|
|
|
this.maxCachedSessions = 100;
|
|
|
|
|
|
|
|
this._sessionCache = {
|
|
|
|
map: {},
|
2023-02-12 19:26:21 +01:00
|
|
|
list: [],
|
2015-07-22 21:18:38 -07:00
|
|
|
};
|
2012-02-18 15:01:35 -08:00
|
|
|
}
|
2019-11-22 18:04:46 +01:00
|
|
|
ObjectSetPrototypeOf(Agent.prototype, HttpAgent.prototype);
|
|
|
|
ObjectSetPrototypeOf(Agent, HttpAgent);
|
2013-05-21 14:02:18 -07:00
|
|
|
Agent.prototype.createConnection = createConnection;
|
2011-02-23 14:46:35 -08:00
|
|
|
|
2021-05-08 04:57:48 +04:30
|
|
|
/**
|
|
|
|
* Gets a unique name for a set of options.
|
|
|
|
* @param {{
|
|
|
|
* host: string;
|
|
|
|
* port: number;
|
|
|
|
* localAddress: string;
|
|
|
|
* family: number;
|
|
|
|
* }} [options]
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-05-21 17:53:17 +08:00
|
|
|
Agent.prototype.getName = function getName(options = kEmptyObject) {
|
2020-11-17 13:10:49 +01:00
|
|
|
let name = FunctionPrototypeCall(HttpAgent.prototype.getName, this, options);
|
2013-05-22 18:44:24 -07:00
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.ca)
|
|
|
|
name += options.ca;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.cert)
|
|
|
|
name += options.cert;
|
|
|
|
|
2016-04-15 16:49:36 +02:00
|
|
|
name += ':';
|
|
|
|
if (options.clientCertEngine)
|
|
|
|
name += options.clientCertEngine;
|
|
|
|
|
2013-05-22 18:44:24 -07:00
|
|
|
name += ':';
|
|
|
|
if (options.ciphers)
|
|
|
|
name += options.ciphers;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.key)
|
|
|
|
name += options.key;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.pfx)
|
|
|
|
name += options.pfx;
|
|
|
|
|
|
|
|
name += ':';
|
2015-01-28 20:05:53 -05:00
|
|
|
if (options.rejectUnauthorized !== undefined)
|
2013-05-22 18:44:24 -07:00
|
|
|
name += options.rejectUnauthorized;
|
|
|
|
|
2015-12-22 13:22:52 -05:00
|
|
|
name += ':';
|
|
|
|
if (options.servername && options.servername !== options.host)
|
|
|
|
name += options.servername;
|
|
|
|
|
2018-05-06 13:52:34 +09:00
|
|
|
name += ':';
|
|
|
|
if (options.minVersion)
|
|
|
|
name += options.minVersion;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.maxVersion)
|
|
|
|
name += options.maxVersion;
|
|
|
|
|
2016-11-02 23:20:12 +01:00
|
|
|
name += ':';
|
|
|
|
if (options.secureProtocol)
|
|
|
|
name += options.secureProtocol;
|
|
|
|
|
2017-10-16 21:23:29 -07:00
|
|
|
name += ':';
|
|
|
|
if (options.crl)
|
|
|
|
name += options.crl;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.honorCipherOrder !== undefined)
|
|
|
|
name += options.honorCipherOrder;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.ecdhCurve)
|
|
|
|
name += options.ecdhCurve;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.dhparam)
|
|
|
|
name += options.dhparam;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.secureOptions !== undefined)
|
|
|
|
name += options.secureOptions;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.sessionIdContext)
|
|
|
|
name += options.sessionIdContext;
|
|
|
|
|
2020-12-06 19:06:07 +01:00
|
|
|
name += ':';
|
|
|
|
if (options.sigalgs)
|
|
|
|
name += JSONStringify(options.sigalgs);
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.privateKeyIdentifier)
|
|
|
|
name += options.privateKeyIdentifier;
|
|
|
|
|
|
|
|
name += ':';
|
|
|
|
if (options.privateKeyEngine)
|
|
|
|
name += options.privateKeyEngine;
|
|
|
|
|
2013-05-22 18:44:24 -07:00
|
|
|
return name;
|
|
|
|
};
|
|
|
|
|
2015-07-22 21:18:38 -07:00
|
|
|
Agent.prototype._getSession = function _getSession(key) {
|
|
|
|
return this._sessionCache.map[key];
|
|
|
|
};
|
|
|
|
|
|
|
|
Agent.prototype._cacheSession = function _cacheSession(key, session) {
|
2015-12-11 20:11:17 -05:00
|
|
|
// Cache is disabled
|
|
|
|
if (this.maxCachedSessions === 0)
|
|
|
|
return;
|
|
|
|
|
2015-07-22 21:18:38 -07:00
|
|
|
// Fast case - update existing entry
|
|
|
|
if (this._sessionCache.map[key]) {
|
|
|
|
this._sessionCache.map[key] = session;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put new entry
|
|
|
|
if (this._sessionCache.list.length >= this.maxCachedSessions) {
|
2020-11-17 13:10:49 +01:00
|
|
|
const oldKey = ArrayPrototypeShift(this._sessionCache.list);
|
2015-07-22 21:18:38 -07:00
|
|
|
debug('evicting %j', oldKey);
|
|
|
|
delete this._sessionCache.map[oldKey];
|
|
|
|
}
|
|
|
|
|
2020-11-17 13:10:49 +01:00
|
|
|
ArrayPrototypePush(this._sessionCache.list, key);
|
2015-07-22 21:18:38 -07:00
|
|
|
this._sessionCache.map[key] = session;
|
|
|
|
};
|
|
|
|
|
2016-01-30 18:49:11 -05:00
|
|
|
Agent.prototype._evictSession = function _evictSession(key) {
|
2020-11-17 13:10:49 +01:00
|
|
|
const index = ArrayPrototypeIndexOf(this._sessionCache.list, key);
|
2016-01-30 18:49:11 -05:00
|
|
|
if (index === -1)
|
|
|
|
return;
|
|
|
|
|
2020-11-17 13:10:49 +01:00
|
|
|
ArrayPrototypeSplice(this._sessionCache.list, index, 1);
|
2016-01-30 18:49:11 -05:00
|
|
|
delete this._sessionCache.map[key];
|
|
|
|
};
|
|
|
|
|
2022-06-21 14:50:55 +02:00
|
|
|
const globalAgent = new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 });
|
2011-02-23 14:46:35 -08:00
|
|
|
|
2021-05-08 04:57:48 +04:30
|
|
|
/**
|
|
|
|
* Makes a request to a secure web server.
|
|
|
|
* @param {...any} args
|
|
|
|
* @returns {ClientRequest}
|
|
|
|
*/
|
2018-07-29 01:00:28 -04:00
|
|
|
function request(...args) {
|
|
|
|
let options = {};
|
|
|
|
|
|
|
|
if (typeof args[0] === 'string') {
|
2020-11-17 13:10:49 +01:00
|
|
|
const urlStr = ArrayPrototypeShift(args);
|
2021-01-09 18:17:43 +05:30
|
|
|
options = urlToHttpOptions(new URL(urlStr));
|
2023-02-27 09:31:18 -05:00
|
|
|
} else if (isURL(args[0])) {
|
2021-01-06 16:10:28 +08:00
|
|
|
options = urlToHttpOptions(ArrayPrototypeShift(args));
|
2018-07-29 01:00:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0] && typeof args[0] !== 'function') {
|
2020-11-17 13:10:49 +01:00
|
|
|
ObjectAssign(options, ArrayPrototypeShift(args));
|
2014-02-25 14:15:02 -08:00
|
|
|
}
|
2018-07-29 01:00:28 -04:00
|
|
|
|
2018-12-21 20:17:15 +02:00
|
|
|
options._defaultAgent = module.exports.globalAgent;
|
2020-11-17 13:10:49 +01:00
|
|
|
ArrayPrototypeUnshift(args, options);
|
2018-07-29 01:00:28 -04:00
|
|
|
|
2020-11-17 13:10:49 +01:00
|
|
|
return ReflectConstruct(ClientRequest, args);
|
2017-10-22 17:23:43 -07:00
|
|
|
}
|
2011-01-21 13:21:01 -08:00
|
|
|
|
2021-05-08 04:57:48 +04:30
|
|
|
/**
|
|
|
|
* Makes a GET request to a secure web server.
|
|
|
|
* @param {string | URL} input
|
|
|
|
* @param {{
|
|
|
|
* agent?: Agent | boolean;
|
|
|
|
* auth?: string;
|
|
|
|
* createConnection?: Function;
|
|
|
|
* defaultPort?: number;
|
|
|
|
* family?: number;
|
2022-03-26 20:48:11 -07:00
|
|
|
* headers?: object;
|
2021-05-08 04:57:48 +04:30
|
|
|
* hints?: number;
|
|
|
|
* host?: string;
|
|
|
|
* hostname?: string;
|
|
|
|
* insecureHTTPParser?: boolean;
|
2023-09-29 20:14:24 +09:00
|
|
|
* joinDuplicateHeaders?: boolean;
|
2021-05-08 04:57:48 +04:30
|
|
|
* localAddress?: string;
|
|
|
|
* localPort?: number;
|
|
|
|
* lookup?: Function;
|
|
|
|
* maxHeaderSize?: number;
|
|
|
|
* method?: string;
|
|
|
|
* path?: string;
|
|
|
|
* port?: number;
|
|
|
|
* protocol?: string;
|
|
|
|
* setHost?: boolean;
|
|
|
|
* socketPath?: string;
|
|
|
|
* timeout?: number;
|
|
|
|
* signal?: AbortSignal;
|
2023-09-29 20:14:24 +09:00
|
|
|
* uniqueHeaders?: Array;
|
2021-05-08 04:57:48 +04:30
|
|
|
* } | string | URL} [options]
|
|
|
|
* @param {Function} [cb]
|
|
|
|
* @returns {ClientRequest}
|
|
|
|
*/
|
2018-07-29 01:00:28 -04:00
|
|
|
function get(input, options, cb) {
|
|
|
|
const req = request(input, options, cb);
|
2014-02-25 14:15:02 -08:00
|
|
|
req.end();
|
|
|
|
return req;
|
2017-10-22 17:23:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Agent,
|
|
|
|
globalAgent,
|
|
|
|
Server,
|
|
|
|
createServer,
|
|
|
|
get,
|
2023-02-12 19:26:21 +01:00
|
|
|
request,
|
2011-01-21 13:21:01 -08:00
|
|
|
};
|