lib/agent.js
function getAgentByUrl (requestUrl) {
  if (!requestUrl) {
    return null;
  }
  var parsedRequestUrl = url.parse(requestUrl);
  var proxyUrl = getSystemProxyByUrl(parsedRequestUrl);
  if (!proxyUrl) {
    log.debug('No system proxy');
    return null;
  }

  log.debug('Detect system proxy Url: ' + proxyUrl);
  var parsedProxyUrl = url.parse(proxyUrl);
  var tunnelOptions = getTunnelOptionsByProxy(parsedProxyUrl, parsedRequestUrl);
  if (tunnelOptions) {
    var tunnelFnName = getTunnelFnName(parsedProxyUrl, parsedRequestUrl);
    log.debug('Tunnel name is ' + tunnelFnName);
    return tunnel[tunnelFnName](tunnelOptions);
  }
}
function getAgentByUrl (requestUrl) {
  if (!requestUrl) {
    return null;
  }
  var parsedRequestUrl = url.parse(requestUrl);
  var proxyUrl = getSystemProxyByUrl(parsedRequestUrl);
  if (!proxyUrl) {
    log.debug('No system proxy');
    return null;
  }

  log.debug('Detect system proxy Url: ' + proxyUrl);
  var parsedProxyUrl = url.parse(proxyUrl);
  var tunnelOptions = getTunnelOptionsByProxy(parsedProxyUrl, parsedRequestUrl);
  if (tunnelOptions) {
    var tunnelFnName = getTunnelFnName(parsedProxyUrl, parsedRequestUrl);
    log.debug('Tunnel name is ' + tunnelFnName);
    return tunnel[tunnelFnName](tunnelOptions);
  }
}
function getAgentByUrl ( requestUrl ) { if ( ! requestUrl ) { return null ; } var parsedRequestUrl = url . parse ( requestUrl ) ; var proxyUrl = getSystemProxyByUrl ( parsedRequestUrl ) ; if ( ! proxyUrl ) { log . debug ( 'No system proxy' ) ; return null ; } log . debug ( 'Detect system proxy Url: ' + proxyUrl ) ; var parsedProxyUrl = url . parse ( proxyUrl ) ; var tunnelOptions = getTunnelOptionsByProxy ( parsedProxyUrl , parsedRequestUrl ) ; if ( tunnelOptions ) { var tunnelFnName = getTunnelFnName ( parsedProxyUrl , parsedRequestUrl ) ; log . debug ( 'Tunnel name is ' + tunnelFnName ) ; return tunnel [ tunnelFnName ] ( tunnelOptions ) ; } }
Get agent only if it has system proxy
Get agent only if it has system proxy