| author | mhabersack | 2010-06-02 10:53:56 (GMT) |
|---|---|---|
| committer | mhabersack | 2010-06-02 10:53:56 (GMT) |
| commit | 14a7aa0d67a9c9b6c0a95cfcbcf0a048d7f073f2 (patch) (side-by-side diff) | |
| tree | 9d9683c01cde1e2135c3a9ee6729f9c838aefb8c | |
| parent | 61f09f196e087f966ce5a7d8f7686b4cebbc3890 (diff) | |
| download | mcs-master.tar.gz | |
* DefaultHttpHandler.cs: implemented, so that static file requests
work again in 4.0
git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@158329 e3ebcda4-bce8-0310-ba0a-eca2169e7518
| -rw-r--r-- | class/System.Web/System.Web/ChangeLog | 5 | ||||
| -rw-r--r-- | class/System.Web/System.Web/DefaultHttpHandler.cs | 70 |
2 files changed, 66 insertions, 9 deletions
diff --git a/class/System.Web/System.Web/ChangeLog b/class/System.Web/System.Web/ChangeLog index f0022cd..cc0c887 100644 --- a/class/System.Web/System.Web/ChangeLog +++ b/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,8 @@ +2010-06-02 Marek Habersack <mhabersack@novell.com> + + * DefaultHttpHandler.cs: implemented, so that static file requests + work again in 4.0 + 2010-06-01 Marek Habersack <mhabersack@novell.com> * HttpUtility.cs: moved chunks of code to the new diff --git a/class/System.Web/System.Web/DefaultHttpHandler.cs b/class/System.Web/System.Web/DefaultHttpHandler.cs index c46d5cc..3a0acd0 100644 --- a/class/System.Web/System.Web/DefaultHttpHandler.cs +++ b/class/System.Web/System.Web/DefaultHttpHandler.cs @@ -28,42 +28,94 @@ // using System.Collections.Specialized; +using System.Threading; namespace System.Web { public class DefaultHttpHandler : IHttpAsyncHandler { + sealed class DefaultHandlerAsyncResult : IAsyncResult + { + public object AsyncState { + get; + private set; + } + + public WaitHandle AsyncWaitHandle { + get { return null; } + } + + public bool CompletedSynchronously { + get { return true; } + } + + public bool IsCompleted { + get { return true; } + } + + public DefaultHandlerAsyncResult (AsyncCallback callback, object state) + { + this.AsyncState = state; + + if (callback != null) + callback (this); + } + } + + NameValueCollection executeUrlHeaders; + protected HttpContext Context { - get { return null; } + get; + private set; } public virtual bool IsReusable { get { return false; } } - - [MonoTODO("Not implemented, always returns null")] + protected NameValueCollection ExecuteUrlHeaders { - get { return null; } + get { + HttpContext context = Context; + HttpRequest req = context != null ? context.Request : null; + if (req != null && executeUrlHeaders != null) + executeUrlHeaders = new NameValueCollection (req.Headers); + + return executeUrlHeaders; + } } - [MonoTODO("Not implemented, always returns null")] public virtual IAsyncResult BeginProcessRequest (HttpContext context, AsyncCallback callback, object state) { - return null; + this.Context = context; + + HttpRequest req = context != null ? context.Request : null; + string filePath = req != null ? req.FilePath : null; + + if (!String.IsNullOrEmpty (filePath) && String.Compare (".asp", VirtualPathUtility.GetExtension (filePath), StringComparison.OrdinalIgnoreCase) == 0) + throw new HttpException (String.Format ("Access to file '{0}' is forbidden.", filePath)); + + if (req != null && String.Compare ("POST", req.HttpMethod, StringComparison.OrdinalIgnoreCase) == 0) + throw new HttpException (String.Format ("Method '{0}' is not allowed when accessing file '{1}'", req.HttpMethod, filePath)); + + var sfh = new StaticFileHandler (); + sfh.ProcessRequest (context); + + return new DefaultHandlerAsyncResult (callback, state); } - [MonoTODO("Not implemented, does nothing")] public virtual void EndProcessRequest (IAsyncResult result) { + // nothing to do } - - [MonoTODO("Not implemented, does nothing")] + public virtual void ProcessRequest (HttpContext context) { + throw new InvalidOperationException ("The ProcessRequest cannot be called synchronously."); } public virtual void OnExecuteUrlPreconditionFailure () { + // nothing to do } public virtual string OverrideExecuteUrlPath () |
