MCPcopy Index your code
hub / github.com/totaljs/framework / download_call

Function download_call

utils.js:1399–1432  ·  view source on GitHub ↗
(uri, options)

Source from the content-addressed store, hash-verified

1397}
1398
1399function download_call(uri, options) {
1400
1401 var opt;
1402 options.length = 0;
1403
1404 if (options.proxy && !options.proxy.tls) {
1405 opt = PROXYOPTIONSHTTP;
1406 opt.port = options.proxy.port;
1407 opt.host = options.proxy.hostname;
1408 opt.path = uri.href;
1409 opt.headers = uri.headers;
1410 opt.method = uri.method;
1411 if (options.proxy._auth)
1412 opt.headers['Proxy-Authorization'] = options.proxy._auth;
1413 } else
1414 opt = uri;
1415
1416 var connection = uri.protocol === 'https:' ? Https : Http;
1417 var req = options.post ? connection.request(opt, download_response) : connection.get(opt, download_response);
1418
1419 req.$options = options;
1420 req.$uri = uri;
1421
1422 if (!options.callback) {
1423 req.on('error', NOOP);
1424 return;
1425 }
1426
1427 req.on('error', download_process_error);
1428 options.timeoutid && clearTimeout(options.timeoutid);
1429 options.timeoutid = setTimeout(download_process_timeout, options.timeout);
1430 req.on('response', download_assign_res);
1431 req.end(options.data);
1432}
1433
1434function download_assign_res(response) {
1435 response.req = this;

Callers 3

utils.jsFile · 0.85
download_resolveFunction · 0.85
download_responseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected