Esempio n. 1
0
        public static FavIconDescriptor RequestIcon(string baseUri, IWebProxy proxy, ICredentials credentials)
        {
            if (baseUri == null)
            {
                throw new ArgumentNullException("baseUri");
            }

            if (proxy == null)
            {
                proxy = GlobalProxySelection.GetEmptyWebProxy();
            }

            FavIconDescriptor ico = null;

            try {
                using (Stream stream = AsyncWebRequest.GetSyncResponseStream(baseUri, credentials, "RssBandit", proxy)) {
                    string htmlContent = string.Empty;
                    using (StreamReader reader = new StreamReader(stream)) {
                        htmlContent = reader.ReadToEnd();
                        ico         = RequestIcon(baseUri, htmlContent, proxy, credentials);
                    }
                }
            } catch {
                // no default HTML page to examine for a FavIcon entry.
                // we do not stop here: try to get a direct download by requesting favicon.ico directly
            }

            string realIconUrl = null;

            if (ico == null || ico == FavIconDescriptor.Empty)
            {
                try {
                    Uri b = new Uri(new Uri(baseUri), "favicon.ico");
                    realIconUrl = b.ToString();
                } catch (UriFormatException) {}
            }

            if (realIconUrl == null)
            {
                return(FavIconDescriptor.Empty);
            }

            // now get the icon stream
            using (Stream stream = AsyncWebRequest.GetSyncResponseStream(realIconUrl, credentials, "RssBandit", proxy)) {
                Image img = CheckAndScaleImageFromStream(stream);
                if (img != null)
                {
                    return(new FavIconDescriptor(realIconUrl, baseUri, DateTime.Now, img));
                }
            }

            return(FavIconDescriptor.Empty);
        }
Esempio n. 2
0
 public static FavIconDescriptor RefreshInfo(FavIconDescriptor descriptor, IWebProxy proxy, ICredentials credentials)
 {
     //return RefreshInfo(descriptor, proxy, credentials);
 }
Esempio n. 3
0
 public static FavIconDescriptor RefreshInfo(FavIconDescriptor descriptor, IWebProxy proxy)
 {
     return(RefreshInfo(descriptor, proxy, null));
 }