コード例 #1
0
ファイル: DavHandler.cs プロジェクト: alexiacovlev/Projects
        /// <summary>
        /// Initializes engine.
        /// </summary>
        /// <param name="context">Instance of <see cref="HttpContext"/>.</param>
        /// <returns>Initialized <see cref="DavEngine"/>.</returns>
        private DavEngine initializeEngine(HttpContext context)
        {
            ILogger logger = Logger.Instance;
            var     engine = new DavEngine
            {
                Logger = logger

                         // Use idented responses if debug logging is enabled.
                , OutputXmlFormatting = debugLoggingEnabled ? Formatting.Indented : Formatting.None

                , AutoPutUnderVersionControl = autoPutUnderVersionControl
            };

            engine.License = license;

            // Set custom handler to process GET and HEAD requests to folders and display
            // info about how to connect to server. We are using the same custom handler
            // class (but different instances) here to process both GET and HEAD because
            // these requests are very similar. Some WebDAV clients may fail to connect if HEAD
            // request is not processed.
            var handlerGet  = new MyCustomGetHandler();
            var handlerHead = new MyCustomGetHandler();

            handlerGet.OriginalHandler  = engine.RegisterMethodHandler("GET", handlerGet);
            handlerHead.OriginalHandler = engine.RegisterMethodHandler("HEAD", handlerHead);

            return(engine);
        }
コード例 #2
0
ファイル: DavHandler.cs プロジェクト: alexiacovlev/Projects
        /// <summary>
        /// Enables processing of HTTP Web requests.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the
        /// intrinsic server objects (for example, Request, Response, Session, and Server) used to service
        /// HTTP requests.
        /// </param>
        public void ProcessRequest(HttpContext context)
        {
            DavEngine engine = getOrInitializeEngine(context);

            context.Response.BufferOutput = false;

            using (var sqlDavContext = new DavContext(context))
            {
                engine.Run(sqlDavContext);
            }
        }