internal HtmlNode RecreateNode(LazyUri url, WebRequestOptions cookieDestination, string cachePath) { if (this.ExceptionType != null) { throw Caching.RebuildException(this, url); } if (this.RedirectUrl != null && this.Result == null) { return(null); } HtmlNode html; if (this.DataType == WebCacheDataType.Json) { html = FizzlerCustomSelectors.JsonToHtml(this.Result, 0, null); } else if (this.DataType == WebCacheDataType.Text) { var d = new HtmlDocument(); html = d.DocumentNode; html.SetAttributeValue("plain-text", "1"); html.AppendTextNode(this.Result); } else { html = this.Result.AsHtmlDocumentNode(); } var docnode = html.OwnerDocument.DocumentNode; docnode.SetAttributeValue("from-cache", "1"); if (this.Headers != null) { foreach (var header in this.Headers) { docnode.SetAttributeValue("header-" + header.Key, header.Value); } } if (this.Cookies != null) { foreach (var cookie in this.Cookies) { cookieDestination.AddCookie(cookie.Key, cookie.Value, PriorityCookie.PRIORITY_FromCache); } } #if DESKTOP if (this.DateRetrieved == default(DateTime)) { this.DateRetrieved = File.GetLastWriteTimeUtc(cachePath); } #endif docnode.SetAttributeValue("date-retrieved", this.DateRetrieved.ToString("o")); if (RedirectUrl != null) { docnode.SetAttributeValue("redirect-url", this.RedirectUrl.AbsoluteUri); } docnode.SetAttributeValue("requested-url", url.AbsoluteUri); html.OwnerDocument.SetPageUrl(this.PageUrl ?? this.Url); return(html); }
internal static Task CheckLocalFileAccessAsync(LazyUri url) { #if NET35 return(CompletedTask); #else return(Task.CompletedTask); #endif }
internal HtmlNode RecreateNode(LazyUri url, WebRequestOptions cookieDestination, string cachePath) { if (this.ExceptionType != null) throw Caching.RebuildException(this, url); if (this.RedirectUrl != null && this.Result == null) return null; HtmlNode html; if (this.DataType == WebCacheDataType.Json) html = FizzlerCustomSelectors.JsonToHtml(this.Result, 0, null); else if (this.DataType == WebCacheDataType.Text) { var d = new HtmlDocument(); html = d.DocumentNode; html.SetAttributeValue("plain-text", "1"); html.AppendTextNode(this.Result); } else { html = this.Result.AsHtmlDocumentNode(); } var docnode = html.OwnerDocument.DocumentNode; docnode.SetAttributeValue("from-cache", "1"); if (this.Headers != null) { foreach (var header in this.Headers) { docnode.SetAttributeValue("header-" + header.Key, header.Value); } } if (this.Cookies != null) { foreach (var cookie in this.Cookies) { cookieDestination.AddCookie(cookie.Key, cookie.Value, PriorityCookie.PRIORITY_FromCache); } } #if DESKTOP if (this.DateRetrieved == default(DateTime)) this.DateRetrieved = File.GetLastWriteTimeUtc(cachePath); #endif docnode.SetAttributeValue("date-retrieved", this.DateRetrieved.ToString("o")); if (RedirectUrl != null) docnode.SetAttributeValue("redirect-url", this.RedirectUrl.AbsoluteUri); docnode.SetAttributeValue("requested-url", url.AbsoluteUri); html.OwnerDocument.SetPageUrl(this.PageUrl ?? this.Url); return html; }
internal static bool UrisEqual(LazyUri a, LazyUri b) { if (a == null || b == null) { return((a == null) == (b == null)); } if (object.ReferenceEquals(a, b)) { return(true); } var aa = a.TryGetAbsoluteUriIfCached(); if (aa != null) { var bb = b.TryGetAbsoluteUriIfCached(); if (bb != null) { return(aa == bb); } } if (a.Scheme != b.Scheme) { return(false); } if (a.Authority != b.Authority) { return(false); } if (a.AbsolutePath != b.AbsolutePath) { return(false); } lock (a) { a.LoadInitialFragmentParameters(); a.LoadInitialQueryParameters(); } lock (b) { b.LoadInitialFragmentParameters(); b.LoadInitialQueryParameters(); } if (a.fragmentParameters.Count != b.fragmentParameters.Count) { return(false); } if (a.queryParameters.Count != b.queryParameters.Count) { return(false); } for (int i = 0; i < a.fragmentParameters.Count; i++) { var af = a.fragmentParameters[i]; var bf = b.fragmentParameters[i]; if (af.Key != bf.Key || af.Value != bf.Value) { return(false); } } for (int i = 0; i < a.queryParameters.Count; i++) { var aq = a.queryParameters[i]; var bq = b.queryParameters[i]; if (aq.Key != bq.Key || aq.Value != bq.Value) { return(false); } } return(true); }
internal static void RaiseWebRequestEvent(LazyUri url, bool fromCache) { }