| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/agent-base/ |
Upload File : |
var url = require('url');
var http = require('http');
var https = require('https');
var semver = require('semver');
var inherits = require('util').inherits;
// we only need to patch the `http.request()` and
// `http.ClientRequest` on older versions of Node.js
if (semver.lt(process.version, '0.11.8')) {
// subclass the native ClientRequest to include the
// passed in `options` object.
http.ClientRequest = (function (_ClientRequest) {
function ClientRequest (options, cb) {
this._options = options;
_ClientRequest.call(this, options, cb);
}
inherits(ClientRequest, _ClientRequest);
return ClientRequest;
})(http.ClientRequest);
// need to re-define the `request()` method, since on node v0.8/v0.10
// the closure-local ClientRequest is used, rather than the monkey
// patched version we have created here.
http.request = (function (request) {
return function (options, cb) {
if (typeof options === 'string') {
options = url.parse(options);
}
if (options.protocol && options.protocol !== 'http:') {
throw new Error('Protocol:' + options.protocol + ' not supported.');
}
return new http.ClientRequest(options, cb);
};
})(http.request);
}
// this currently needs to be applied to all Node.js versions
// (v0.8.x, v0.10.x, v0.12.x), in order to determine if the `req`
// is an HTTP or HTTPS request. There is currently no PR attempting
// to move this property upstream.
https.request = (function (request) {
return function (options, cb) {
if (typeof options === 'string') {
options = url.parse(options);
}
if (null == options.port) options.port = 443;
options.secureEndpoint = true;
return request.call(https, options, cb);
};
})(https.request);