PageRenderTime 28ms CodeModel.GetById 25ms app.highlight 1ms 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
 1<%@ WebHandler Language="C#" Class="apmlchecker" %>
 2
 3using System;
 4using System.Web;
 5using System.Collections.Generic;
 6using System.Xml;
 7using BlogEngine.Core;
 8
 9public class apmlchecker : IHttpHandler
10{
11
12  public void ProcessRequest(HttpContext context)
13  {
14    context.Response.ContentType = "text/plain";
15    string website = context.Request.QueryString["url"];
16
17    Uri apml = RetrieveApmlUrl(context, website);
18    if (apml != null)
19    {
20      context.Response.Write(apml);
21    }
22
23    BlogEngine.Core.Web.HttpModules.CompressionModule.CompressResponse(context);
24    context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
25    context.Response.Cache.VaryByParams["url"] = true;
26    context.Response.Cache.SetValidUntilExpires(true);
27    context.Response.Cache.SetMaxAge(new TimeSpan(0, 10, 0));
28  }
29
30  private static Uri RetrieveApmlUrl(HttpContext context, string website)
31  {
32    Uri url;
33    if (Uri.TryCreate(website, UriKind.Absolute, out url))
34    {
35      Dictionary<Uri, XmlDocument> docs = Utils.FindSemanticDocuments(url, "apml");
36      if (docs.Count > 0)
37      {
38        foreach (Uri key in docs.Keys)
39        {
40          return key;
41        }
42      }
43    }
44
45    return null;
46  }
47
48  public bool IsReusable
49  {
50    get
51    {
52      return false;
53    }
54  }
55
56}