Esempio n. 1
0
        /// <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 override async Task ProcessRequestAsync(HttpContext context)
        {
            DavEngineAsync webDavEngine = getOrInitializeWebDavEngine(context);

            context.Response.BufferOutput = false;
            DavContext        ntfsDavContext = new DavContext(context);
            GSuiteEngineAsync gSuiteEngine   = getOrInitializeGSuiteEngine(context);
            await webDavEngine.RunAsync(ntfsDavContext);

            if (gSuiteEngine != null)
            {
                await gSuiteEngine.RunAsync(ContextConverter.ConvertToGSuiteContext(ntfsDavContext));
            }
        }
Esempio n. 2
0
        private static async Task ProcessRequestAsync(System.Net.HttpListener listener, HttpListenerContext context)
        {
            try
            {
                MacOsXPreprocessor.Process(context.Request); // fixes headers for Mac OS X v10.5.3 or later

                IPrincipal principal = null;
                if (context.Request.IsWebSocketRequest && context.Request.RawUrl.StartsWith("/dav"))
                {
                    // If current request is web socket request.
                    await ProcessWebSocketRequestAsync(context);

                    return;
                }

                context.Response.SendChunked = false;

                var ntfsDavContext =
                    new DavContext(context, listener.Prefixes, principal, repositoryPath, webDavEngine.Logger);

                if ((principal != null) && principal.Identity.IsAuthenticated)
                {
                }
                await webDavEngine.RunAsync(ntfsDavContext);

                if (gSuiteEngine != null)
                {
                    await gSuiteEngine.RunAsync(ContextConverter.ConvertToGSuiteContext(ntfsDavContext));
                }

                if (context.Response.StatusCode == 401)
                {
                    ShowLoginDialog(context, context.Response);
                }
            }
            finally
            {
                if (context != null && context.Response != null)
                {
                    try
                    {
                        context.Response.Close();
                    }
                    catch
                    {
                        // client closed connection before the content was sent
                    }
                }
            }
        }
Esempio n. 3
0
        public void ContextConverterTest()
        {
            ContextConverter conv = new ContextConverter();
            var eachCntx          = new EachContext <string>();

            eachCntx.Index = 1;
            eachCntx.Item  = "a";
            Assert.IsTrue(conv.CanConvert(eachCntx.GetType(), typeof(IDictionary)));
            Assert.IsTrue(conv.CanConvert(eachCntx.GetType(), typeof(IDictionary <string, object>)));
            Assert.IsFalse(conv.CanConvert(eachCntx.GetType(), typeof(IDictionary <string, string>)));

            var dictCntx = (IDictionary)conv.Convert(eachCntx, typeof(IDictionary));

            Assert.AreEqual(1, dictCntx["Index"]);

            var gDictCntx = (IDictionary <string, object>)conv.Convert(eachCntx, typeof(IDictionary <string, object>));

            Assert.AreEqual("a", dictCntx["Item"]);
        }
Esempio n. 4
0
        private static async Task ProcessRequestAsync(System.Net.HttpListener listener, HttpListenerContext context)
        {
            try
            {
                MacOsXPreprocessor.Process(context.Request); // fixes headers for Mac OS X v10.5.3 or later

                IPrincipal principal = null;
                if (context.Request.IsWebSocketRequest && context.Request.RawUrl.StartsWith("/dav"))
                {
                    // If current request is web socket request.
                    await ProcessWebSocketRequestAsync(context);

                    return;
                }

                context.Response.SendChunked = false;

                using (var sqlDavContext = new DavContext(context, listener.Prefixes, principal, webDavEngine.Logger))
                {
                    await webDavEngine.RunAsync(sqlDavContext);

                    if (gSuiteEngine != null)
                    {
                        await gSuiteEngine.RunAsync(ContextConverter.ConvertToGSuiteContext(sqlDavContext));
                    }
                }
            }
            finally
            {
                if (context != null && context.Response != null)
                {
                    try
                    {
                        context.Response.Close();
                    }
                    catch
                    {
                        // client closed connection before the content was sent
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Processes GSuite request.
        /// </summary>
        public async Task Invoke(HttpContext context, ContextCoreAsync <IHierarchyItemAsync> davContext)
        {
            await engine.RunAsync(ContextConverter.ConvertToGSuiteContext(davContext));

            await next(context);
        }
Esempio n. 6
0
 public FormMain()
 {
     InitializeComponent();
     contextConverter = new ContextConverter();
 }