diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 25c1ca3..411c8c5 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -51,6 +51,7 @@ + diff --git a/IISMainHandler/MainHandler.cs b/IISMainHandler/MainHandler.cs index 8a500b9..4d70c4b 100644 --- a/IISMainHandler/MainHandler.cs +++ b/IISMainHandler/MainHandler.cs @@ -28,8 +28,12 @@ namespace FLocal.IISHandler { } WebContext context = new WebContext(httpcontext); - ISpecificHandler handler = HandlersFactory.getHandler(context); - handler.Handle(context); + try { + ISpecificHandler handler = HandlersFactory.getHandler(context); + handler.Handle(context); + } catch(WrongUrlException) { + (new handlers.WrongUrlHandler()).Handle(context); + } } public void ProcessRequest(HttpContext context) { diff --git a/IISMainHandler/exceptions/WrongUrlException.cs b/IISMainHandler/exceptions/WrongUrlException.cs new file mode 100644 index 0000000..dbfad89 --- /dev/null +++ b/IISMainHandler/exceptions/WrongUrlException.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FLocal.Core; + +namespace FLocal.IISHandler { + class WrongUrlException : FLocalException { + + public WrongUrlException() : base("wrong url") { + } + + } +} diff --git a/IISMainHandler/handlers/StaticHandler.cs b/IISMainHandler/handlers/StaticHandler.cs index 7feea22..bc42cb8 100644 --- a/IISMainHandler/handlers/StaticHandler.cs +++ b/IISMainHandler/handlers/StaticHandler.cs @@ -18,32 +18,37 @@ namespace FLocal.IISHandler.handlers { public void Handle(WebContext context) { if(this.requestParts.Length < 2) { - throw new HttpException(403, "listing not allowed"); + //throw new HttpException(403, "listing not allowed"); + throw new WrongUrlException(); } Regex checker = new Regex("^[a-z][0-9a-z\\-_]*(\\.[a-zA-Z]+)?$", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Singleline); string path = ""; for(int i=1; i