コード例 #1
0
            public Uri GetProxy(Uri destination)
            {
                IList <Java.Net.Proxy> list;

                using (var uri = CreateJavaUri(destination))
                    list = selector.Select(uri) !;
                if (list.Count < 1)
                {
                    return(destination);
                }

                var proxy = list [0];

                if (proxy.Equals(Proxy.NoProxy))
                {
                    return(destination);
                }

                var address = proxy.Address() as InetSocketAddress;

                if (address == null)                 // FIXME
                {
                    return(destination);
                }

#if ANDROID_19
                return(new Uri(string.Format("http://{0}:{1}/", address.HostString, address.Port)));
#else
                return(new Uri(string.Format("http://{0}:{1}/", address.HostName, address.Port)));
#endif
            }
コード例 #2
0
ファイル: HttpSupport.cs プロジェクト: shoff/ngit
 /// <summary>Determine the proxy server (if any) needed to obtain a URL.</summary>
 /// <remarks>Determine the proxy server (if any) needed to obtain a URL.</remarks>
 /// <param name="proxySelector">proxy support for the caller.</param>
 /// <param name="u">location of the server caller wants to talk to.</param>
 /// <returns>proxy to communicate with the supplied URL.</returns>
 /// <exception cref="Sharpen.ConnectException">
 /// the proxy could not be computed as the supplied URL could not
 /// be read. This failure should never occur.
 /// </exception>
 public static Proxy ProxyFor(ProxySelector proxySelector, Uri u)
 {
     try
     {
         return(proxySelector.Select(u.ToURI())[0]);
     }
     catch (URISyntaxException e)
     {
         ConnectException err;
         err = new ConnectException(MessageFormat.Format(JGitText.Get().cannotDetermineProxyFor
                                                         , u));
         Sharpen.Extensions.InitCause(err, e);
         throw err;
     }
 }