/// <exception cref="Apache.Http.HttpException"></exception>
        protected internal override HttpHost DetermineProxy(HttpHost target, IHttpRequest
                                                            request, HttpContext context)
        {
            URI targetURI;

            try
            {
                targetURI = new URI(target.ToURI());
            }
            catch (URISyntaxException ex)
            {
                throw new HttpException("Cannot convert host to URI: " + target, ex);
            }
            IList <Proxy> proxies = this.proxySelector.Select(targetURI);
            Proxy         p       = ChooseProxy(proxies);
            HttpHost      result  = null;

            if (p.Type() == Proxy.Type.Http)
            {
                // convert the socket address to an HttpHost
                if (!(p.Address() is IPEndPoint))
                {
                    throw new HttpException("Unable to handle non-Inet proxy address: " + p.Address()
                                            );
                }
                IPEndPoint isa = (IPEndPoint)p.Address();
                // assume default scheme (http)
                result = new HttpHost(GetHost(isa), isa.Port);
            }
            return(result);
        }