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); }
public static FavIconDescriptor RefreshInfo(FavIconDescriptor descriptor, IWebProxy proxy, ICredentials credentials) { //return RefreshInfo(descriptor, proxy, credentials); }
public static FavIconDescriptor RefreshInfo(FavIconDescriptor descriptor, IWebProxy proxy) { return(RefreshInfo(descriptor, proxy, null)); }