From e5569677257dc2c0c950c61b01bc5be25ca3facc Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Tue, 13 Jul 2010 06:47:00 +0000 Subject: [PATCH] Robots handler implemented --- IISMainHandler/HandlersFactory.cs | 8 +++++++ IISMainHandler/IISMainHandler.csproj | 1 + .../handlers/response/RobotsHandler.cs | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 IISMainHandler/handlers/response/RobotsHandler.cs diff --git a/IISMainHandler/HandlersFactory.cs b/IISMainHandler/HandlersFactory.cs index bbbe3f2..c47b5dc 100644 --- a/IISMainHandler/HandlersFactory.cs +++ b/IISMainHandler/HandlersFactory.cs @@ -27,6 +27,12 @@ namespace FLocal.IISHandler { } #endregion + #region robots + if(context.httprequest.Path.ToLower().StartsWith("/robots.txt")) { + return new handlers.response.RobotsHandler(); + } + #endregion + switch(context.requestParts[0].ToLower()) { case "q": return new handlers.response.QuickLinkHandler(); @@ -97,6 +103,8 @@ namespace FLocal.IISHandler { return new handlers.response.UserPostsHandler(); case "replies": return new handlers.response.UserRepliesHandler(); + case "pollsparticipated": + return new handlers.response.UserPollsParticipatedHandler(); default: return new handlers.WrongUrlHandler(); } diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 7e4276a..80e14e4 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -97,6 +97,7 @@ + diff --git a/IISMainHandler/handlers/response/RobotsHandler.cs b/IISMainHandler/handlers/response/RobotsHandler.cs new file mode 100644 index 0000000..a3581ab --- /dev/null +++ b/IISMainHandler/handlers/response/RobotsHandler.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using System.Text.RegularExpressions; +using System.IO; +using FLocal.Core; + +namespace FLocal.IISHandler.handlers.response { + class RobotsHandler : ISpecificHandler { + + public RobotsHandler() { + } + + public void Handle(WebContext context) { + context.httpresponse.ContentType = "text/plain"; + context.httpresponse.WriteLine("User-agent: *"); + context.httpresponse.WriteLine("Disallow: /"); + } + + } +}