protected override void HandleHttpRequest(Connection connection, HttpServerRequest request, HttpServerResponse response)
{
base.HandleHttpRequest(connection, request, response);
if (response.ContentSource == ContentSource.ContentNone)
{
if (request.Header.RequestType == "GET")
{
String lPath = RootPath + request.Header.RequestPath.Replace('/', Path.DirectorySeparatorChar);
if (lPath.IndexOf("..") == -1)
{
if (File.Exists(lPath))
{
response.Header.ContentType = "text/html";
response.ContentStream = new FileStream(lPath, FileMode.Open, FileAccess.Read, FileShare.Read);
response.CloseStream = true; /* Response will close stream once it's been sent */
}
else
{
response.SendError(HttpStatusCode.NotFound, String.Format("File '{0}' not found.", lPath));
}
}
else
{
response.SendError(HttpStatusCode.Forbidden, String.Format("Bad Request: Path '{0}' contains '..' which is invalid.", lPath));
}
}
else
{
response.SendError(HttpStatusCode.BadRequest, String.Format("Request Type '{0}' not supported.", request.Header.RequestType));
}
}
}