public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
try{
Hashtable hash = new Hashtable();
// Set up the template with useful details and the challenge and public key.
hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);
if (AjaxLife.HANDLE_CONTENT_ENCODING)
{
hash.Add("ENCODING", "identity");
// S3 doesn't support Accept-Encoding, so we do it ourselves.
if (request.Headers["Accept-Encoding"] != null)
{
string[] accept = request.Headers["Accept-Encoding"].Split(',');
foreach (string encoding in accept)
{
string parsedencoding = encoding.Split(';')[0].Trim();
if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
{
hash["ENCODING"] = "gzip";
break;
}
}
}
}
Html.Template.Parser parser = new Html.Template.Parser(hash);
writer.Write(parser.Parse(File.ReadAllText("Html/Templates/index.html")));
}catch(Exception exception){
this.contenttype = "text/plain";
writer.WriteLine("Error: " + exception.Message);
}
writer.Flush();
}