Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const transportUrls = this.getEndpoints();
let _sessionId;
let client;
for (let h = 0; h < hostLength; h++) {
// node client
if (isNode) {
const connectOptions = {
transport: Thrift.TBufferedTransport,
protocol: Thrift.TJSONProtocol,
path: '/',
headers: { Connection: 'close' },
https: this._protocol[h] === 'https',
};
const connection = Thrift.createHttpConnection(
this._host[h],
this._port[h],
connectOptions
);
connection.on('error', _logError);
client = Thrift.createClient(MapD, connection);
}
// browser client
if (hasWindow) {
const transport = new window.Thrift.Transport(transportUrls[h]);
const protocol = new window.Thrift.Protocol(transport);
client = new MapDClient(protocol);
}
// sync
}
var thriftOptions = {
transport : thrift.TBufferedTransport,
protocol : thrift.TBinaryProtocol,
path : "/_rpc/v1/reports/binary",
https : (opts.collector_encryption !== 'none'),
nodeOptions : {},
};
if (!opts.certificate_verification) {
// https://github.com/request/request/issues/418
thriftOptions.nodeOptions.rejectUnauthorized = false;
thriftOptions.nodeOptions.strictSSL = false;
}
this._connection = thrift.createHttpConnection(opts.collector_host, opts.collector_port, thriftOptions);
this._client = thrift.createHttpClient(crouton_thrift.ReportingServiceClient, this._connection);
}
iclient = (action, callback) => {
try {
const {request: {args, func, host, port}} = action;
action.request.headers = Object.assign(
{"User-Agent": `mimic: ${process.env.MIMIC_VERSION}`},
action.request.headers,
);
const connection = createHttpConnection(host, port, {
transport: ThriftProvider.transports[transport],
protocol: ThriftProvider.protocols[protocol],
path: action.request.path,
headers: Object.assign({"User-Agent": `mimic: ${process.env.MIMIC_VERSION}`}, action.request.headers),
});
connection.on("error", (error) => {
callback(error, action);
});
let headers: any;
const orig = connection.responseCallback;
connection.responseCallback = (response) => {
headers = response.headers;
orig(response);
};
const client: any = createHttpClient(api[service], connection);
action.request.time = Date.now();