(uri, options)
| 1397 | } |
| 1398 | |
| 1399 | function 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 | |
| 1434 | function download_assign_res(response) { |
| 1435 | response.req = this; |
no outgoing calls
no test coverage detected