PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/widgets/Visitor info/apmlchecker.ashx

#
Unknown | 56 lines | 47 code | 9 blank | 0 comment | 0 complexity | 4730342b38e687fff96ea272fb0db265 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. <%@ WebHandler Language="C#" Class="apmlchecker" %>
  2. using System;
  3. using System.Web;
  4. using System.Collections.Generic;
  5. using System.Xml;
  6. using BlogEngine.Core;
  7. public class apmlchecker : IHttpHandler
  8. {
  9. public void ProcessRequest(HttpContext context)
  10. {
  11. context.Response.ContentType = "text/plain";
  12. string website = context.Request.QueryString["url"];
  13. Uri apml = RetrieveApmlUrl(context, website);
  14. if (apml != null)
  15. {
  16. context.Response.Write(apml);
  17. }
  18. BlogEngine.Core.Web.HttpModules.CompressionModule.CompressResponse(context);
  19. context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
  20. context.Response.Cache.VaryByParams["url"] = true;
  21. context.Response.Cache.SetValidUntilExpires(true);
  22. context.Response.Cache.SetMaxAge(new TimeSpan(0, 10, 0));
  23. }
  24. private static Uri RetrieveApmlUrl(HttpContext context, string website)
  25. {
  26. Uri url;
  27. if (Uri.TryCreate(website, UriKind.Absolute, out url))
  28. {
  29. Dictionary<Uri, XmlDocument> docs = Utils.FindSemanticDocuments(url, "apml");
  30. if (docs.Count > 0)
  31. {
  32. foreach (Uri key in docs.Keys)
  33. {
  34. return key;
  35. }
  36. }
  37. }
  38. return null;
  39. }
  40. public bool IsReusable
  41. {
  42. get
  43. {
  44. return false;
  45. }
  46. }
  47. }