Пример #1
0
SharedProxy GetProxyForURL(string& url)
{
    static Logger* logger = GetLogger();
    URI uri(url);

    // Don't try to detect proxy settings for URLs we know are local
    std::string scheme(uri.getScheme());
    if (scheme == "app" || scheme == "ti" || scheme == "file")
        return 0;

    if (scheme == "http" && !httpProxyOverride.isNull())
        return httpProxyOverride;

    if (scheme == "https" && !httpsProxyOverride.isNull())
        return httpsProxyOverride;

    SharedProxy environmentProxy(GetProxyFromEnvironment(scheme));
    if (!environmentProxy.isNull())
    {
        logger->Debug("Found proxy (%s) in environment",
                      environmentProxy->ToString().c_str());
        return environmentProxy;
    }

    logger->Debug("Looking up proxy information for: %s", url.c_str());
    SharedProxy proxy(ProxyConfig::GetProxyForURLImpl(uri));

    if (proxy.isNull())
        logger->Debug("Using direct connection.");
    else
        logger->Debug("Using proxy: %s", proxy->ToString().c_str());

    return proxy;
}
nsresult
nsUnixSystemProxySettings::GetProxyForURI(const nsACString & aSpec,
                                          const nsACString & aScheme,
                                          const nsACString & aHost,
                                          const int32_t      aPort,
                                          nsACString & aResult)
{
  if (mProxySettings) {
    nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
    if (NS_SUCCEEDED(rv))
      return rv;
  }
  if (mGConf)
    return GetProxyFromGConf(aScheme, aHost, aPort, aResult);

  return GetProxyFromEnvironment(aScheme, aHost, aPort, aResult);
}
nsresult
nsUnixSystemProxySettings::GetProxyForURI(nsIURI* aURI, nsACString& aResult)
{
  nsCAutoString scheme;
  nsresult rv = aURI->GetScheme(scheme);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString host;
  rv = aURI->GetHost(host);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 port;
  rv = aURI->GetPort(&port);
  NS_ENSURE_SUCCESS(rv, rv);

  if (!mGConf)
    return GetProxyFromEnvironment(scheme, host, port, aResult);

  return GetProxyFromGConf(scheme, host, port, aResult);
}