private void OutputCache(PageCacheItem value, HttpContext context) { context.Response.BinaryWrite(value.Data); context.Response.BinaryWrite(eofdata); context.Response.Flush(); context.Response.End(); }
private void Cache_WithWeb(HttpContext context, HttpRequest request, string key, UrlItem urlitem) { PageCacheItem data = (PageCacheItem)context.Cache[key]; if (data == null) { Generator_Cache(context, request, key, urlitem); } else { OutputCache(data, context); } }
public override void Execute() { lock (typeof(GetUrlItem)) { PageCacheItem page = new PageCacheItem(); mRequest = (HttpWebRequest)WebRequest.Create(URL); mResponse = (HttpWebResponse)mRequest.GetResponse(); int length = 0; foreach (string key in mResponse.Headers.Keys) { page.Headers.Add(new HeaderItem { Name = key, Value = mResponse.Headers[key] }); if (key == "Content-Length") { int.TryParse(mResponse.Headers[key], out length); } } page.Data = new Byte[length]; int offset = 0; int count; using (System.IO.Stream stream = mResponse.GetResponseStream()) { count = stream.Read(page.Data, offset, page.Data.Length - offset); offset += count; while (count > 0) { count = stream.Read(page.Data, offset, page.Data.Length - offset); offset += count; } } if (Cache != null) { Cache.Remove(Key); Cache.Add(Key, page, null, DateTime.Now.AddMinutes(Item.Expiry), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } }
public override void Execute() { lock (typeof(GetUrlItem)) { PageCacheItem page = new PageCacheItem(); mRequest = (HttpWebRequest)WebRequest.Create(URL); mResponse = (HttpWebResponse)mRequest.GetResponse(); int length = 0; foreach (string key in mResponse.Headers.Keys) { page.Headers.Add(new HeaderItem { Name = key, Value = mResponse.Headers[key] }); if (key == "Content-Length") { int.TryParse(mResponse.Headers[key], out length); } } page.Data = new Byte[length]; int offset = 0; int count; using (System.IO.Stream stream = mResponse.GetResponseStream()) { count = stream.Read(page.Data, offset, page.Data.Length - offset); offset += count; while (count > 0) { count = stream.Read(page.Data, offset, page.Data.Length - offset); offset += count; } } if (Cache != null) { Cache.Remove(Key); Cache.Add(Key, page, null, DateTime.Now.AddMinutes(Item.Expiry), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } }
private void OutputCache(PageCacheItem value, HttpContext context) { context.Response.BinaryWrite(value.Data); context.Response.BinaryWrite(eofdata); context.Response.Flush(); context.Response.End(); }