Beispiel #1
0
        /// <summary>
        /// WebDav Framework method for Dav request processing
        /// </summary>
        /// <param name="httpApplication"></param>
        /// <remarks>
        ///		Process all requests... will return 501 if the requested method is not implemented
        /// </remarks>
        public void ProcessRequest(HttpApplication httpApplication)
        {
            if (httpApplication == null)
            {
                throw new ArgumentNullException("httpApplication", InternalFunctions.GetResourceString("ArgumentNullException", "HttpApplication"));
            }

            //Set the status code to Method Not Allowed by default
            int _statusCode = 405;

            string _httpMethod = httpApplication.Request.HttpMethod;

            InternalFunctions.WriteDebugLog("Processing HttpMethod " + _httpMethod);
            //try
            {
                if (this.__davMethodList.ContainsKey(_httpMethod))
                {
                    httpApplication.Response.Clear();
                    httpApplication.Response.ClearContent();

                    DavMethodBase _davMethodBase = this.DavSourceAssembly.CreateInstance(this.__davMethodList[_httpMethod]) as DavMethodBase;
                    if (_davMethodBase != null)
                    {
                        _davMethodBase.HttpApplication = httpApplication;
                        _statusCode = ((IDavRequest)_davMethodBase).ProcessRequest();
                    }
                }
            }
            //catch (Exception ex)
            //{
            //    InternalFunctions.WriteDebugLog("Error processing HttpMethod " + _httpMethod +
            //        Environment.NewLine + "Message: " + ex.Message);
            //}

            InternalFunctions.WriteDebugLog("Completed processing HttpMethod " + _httpMethod + " status code returned: " + _statusCode);

            if (this.__davMethodList.ContainsKey(_httpMethod))
            {
                httpApplication.Response.StatusCode = _statusCode;


                ////TODO: remove this
                //System.Threading.Thread.Sleep(10000);

                //Perhaps implement...
                //httpApplication.Request.InputStream.Close();
                httpApplication.Response.End();
            }
        }
Beispiel #2
0
        /// <summary>
        /// WebDav Framework method for Dav request processing
        /// </summary>
        /// <param name="httpApplication"></param>
        /// <remarks>
        ///		Process all requests... will return 501 if the requested method is not implemented
        /// </remarks>
        public void ProcessRequest(HttpApplication httpApplication)
        {
            if (httpApplication == null)
            {
                throw new ArgumentNullException("httpApplication", InternalFunctions.GetResourceString("ArgumentNullException", "HttpApplication"));
            }

            var verb = GeneralHelper.GetVerb(httpApplication.Request.HttpMethod);

            var e = XdavEvents.Current.XdavOnProcessingHandler(new XdavOnProcessingEventArg()
            {
                Context  = httpApplication,
                HttpVerp = verb,
                File     = FileWrapper.Current.File
            });

            if (!e.AllowContinue)
            {
                return;
            }


            //Set the status code to Method Not Allowed by default
            int _statusCode = 405;

            string _httpMethod = httpApplication.Request.HttpMethod;

            InternalFunctions.WriteDebugLog("Processing HttpMethod " + _httpMethod);
            try
            {
                if (this.__davMethodList.ContainsKey(_httpMethod))
                {
                    httpApplication.Response.Clear();
                    httpApplication.Response.ClearContent();

                    DavMethodBase _davMethodBase = this.DavSourceAssembly.CreateInstance(this.__davMethodList[_httpMethod]) as DavMethodBase;
                    if (_davMethodBase != null)
                    {
                        _davMethodBase.HttpApplication = httpApplication;
                        _statusCode = ((IDavRequest)_davMethodBase).ProcessRequest();
                    }
                }
            }
            catch (Exception ex)
            {
                XdavEvents.Current.XdavOnExceptionHandler(new XdavOnExceptionEventArg()
                {
                    Exception = ex,
                    Context   = httpApplication,
                    HttpVerp  = verb,
                    File      = FileWrapper.Current.File
                });
            }

            InternalFunctions.WriteDebugLog("Completed processing HttpMethod " + _httpMethod + " status code returned: " + _statusCode);

            if (this.__davMethodList.ContainsKey(_httpMethod))
            {
                httpApplication.Response.StatusCode = _statusCode;


                ////TODO: remove this
                //System.Threading.Thread.Sleep(10000);

                //Perhaps implement...
                //httpApplication.Request.InputStream.Close();
                httpApplication.Response.End();
            }

            XdavEvents.Current.XdavOnProcessedHandler(new XdavOnProcessedEventArg()
            {
                Context    = httpApplication,
                HttpVerp   = verb,
                StatusCode = _statusCode,
                File       = FileWrapper.Current.File
            });
        }