コード例 #1
0
        public override async Task Invoke(IOwinContext context)
        {
            var isPushEnabled = context.Get <bool>(CommonOwinKeys.EnableServerPush);

            //If push is not allowed then pass to then next layer
            if (!isPushEnabled)
            {
                await Next.Invoke(context);

                return;
            }

            bool gotError = false;
            var  refTree  = context.Get <Dictionary <string, string[]> >(CommonOwinKeys.AdditionalInfo);

            //original request from client
            if (refTree == null)
            {
                string root = context.Request.Path.Value;
                if (!_references.ContainsKey(root))
                {
                    gotError = true; // Cant build tree because no such name in the ref table. Should invoke next
                }
                else
                {
                    var refCpy = new ReferenceTable(_references);
                    var tree   = new GraphHelper().BuildTree(refCpy, root);
                    refTree = tree;
                    context.Set(CommonOwinKeys.AdditionalInfo, tree);
                }
            }
            if (!gotError)
            {
                PushFunc pushPromise;
                string[] pushReferences;

                if (refTree.TryGetValue(context.Request.Path.Value, out pushReferences) &&
                    TryGetPushPromise(context, out pushPromise))
                {
                    foreach (var pushReference in pushReferences)
                    {
                        Push(context.Request, pushPromise, pushReference);
                    }
                }
            }

            context.Set(CommonOwinKeys.AddVertex, new AddVertFunc(AddVertex));
            context.Set(CommonOwinKeys.RemoveVertex, new RemoveVertFunc(RemoveVertex));

            await Next.Invoke(context);
        }
コード例 #2
0
ファイル: GraphHelper.cs プロジェクト: Nangal/http2-katana
            private void Dfs(ReferenceTable table, string root)
            {
                _used[root] = true;
                var nonused = new List<string>(8);

                foreach (var child in table[root])
                {
                    if (!_used[child])
                    {
                        nonused.Add(child);
                        Dfs(table, child);
                    }
                }
                _tree.Add(root, nonused.ToArray());
            }
コード例 #3
0
            private void Dfs(ReferenceTable table, string root)
            {
                _used[root] = true;
                var nonused = new List <string>(8);

                foreach (var child in table[root])
                {
                    if (!_used[child])
                    {
                        nonused.Add(child);
                        Dfs(table, child);
                    }
                }
                _tree.Add(root, nonused.ToArray());
            }
コード例 #4
0
ファイル: GraphHelper.cs プロジェクト: Nangal/http2-katana
            public Dictionary<string, string[]> BuildTree(ReferenceTable table, string root)
            {
                if (!table.ContainsKey(root))
                    throw new Exception("No such key. Should invoke next.");

                _used.Clear();
                _tree.Clear();

                foreach (var key in table.Keys)
                {
                    _used.Add(key, false);
                }

                Dfs(table, root);

                return _tree;
            }
コード例 #5
0
            public Dictionary <string, string[]> BuildTree(ReferenceTable table, string root)
            {
                if (!table.ContainsKey(root))
                {
                    throw new Exception("No such key. Should invoke next.");
                }

                _used.Clear();
                _tree.Clear();

                foreach (var key in table.Keys)
                {
                    _used.Add(key, false);
                }

                Dfs(table, root);

                return(_tree);
            }
コード例 #6
0
 public ReferenceTable(ReferenceTable table)
 {
     _collection = new Dictionary <string, string[]>(table._collection, StringComparer.OrdinalIgnoreCase);
 }
コード例 #7
0
ファイル: ReferenceTable.cs プロジェクト: Nangal/http2-katana
 public ReferenceTable(ReferenceTable table)
 {
     _collection = new Dictionary<string, string[]>(table._collection, StringComparer.OrdinalIgnoreCase);
 }
コード例 #8
0
 public PushMiddleware(OwinMiddleware next)
     : base(next)
 {
     _references = new ReferenceTable(new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase)
     {
         {
             "/root/index.html", new[]
             {
                 "/root/simpleTest.txt"
             }
         },
         {
             "/root/simpleTest.txt", new string[0]
         },
         {
             "/root/LookAround.htm", new []
             {
                 "/root/LookAround_files/BaseStyles.css",
                 "/root/LookAround_files/Demo.css",
                 "/root/LookAround_files/DemoTemplate.css",
                 "/root/LookAround_files/FavIcon.ico",
                 "/root/LookAround_files/ie-logo.png",
                 "/root/LookAround_files/instructions.png",
                 "/root/LookAround_files/loading.gif",
                 "/root/LookAround_files/negx.jpg",
                 "/root/LookAround_files/negy.jpg",
                 "/root/LookAround_files/negz.jpg",
                 "/root/LookAround_files/posx.jpg",
                 "/root/LookAround_files/posy.jpg",
                 "/root/LookAround_files/posz.jpg",
                 "/root/LookAround_files/ReturnAndShareControls.css",
                 "/root/LookAround_files/ReturnAndShareControls.js",
                 "/root/LookAround_files/ReturnButtonImageStrip.png",
                 "/root/LookAround_files/TestDriveCommon.js",
                 "/root/LookAround_files/three.min.js",
             }
         },
         {
             "/root/LookAround_files/BaseStyles.css", new string[0]
         },
         {
             "/root/LookAround_files/Demo.css", new string[0]
         },
         {
             "/root/LookAround_files/DemoTemplate.css", new string[0]
         },
         {
             "/root/LookAround_files/FavIcon.ico", new string[0]
         },
         {
             "/root/LookAround_files/ie-logo.png", new string[0]
         },
         {
             "/root/LookAround_files/instructions.png", new string[0]
         },
         {
             "/root/LookAround_files/loading.gif", new string[0]
         },
         {
             "/root/LookAround_files/negx.jpg", new string[0]
         },
         {
             "/root/LookAround_files/negy.jpg", new string[0]
         },
         {
             "/root/LookAround_files/negz.jpg", new string[0]
         },
         {
             "/root/LookAround_files/posx.jpg", new string[0]
         },
         {
             "/root/LookAround_files/posy.jpg", new string[0]
         },
         {
             "/root/LookAround_files/posz.jpg", new string[0]
         },
         {
             "/root/LookAround_files/ReturnAndShareControls.css", new string[0]
         },
         {
             "/root/LookAround_files/ReturnAndShareControls.js", new string[0]
         },
         {
             "/root/LookAround_files/ReturnButtonImageStrip.png", new string[0]
         },
         {
             "/root/LookAround_files/TestDriveCommon.js", new string[0]
         },
         {
             "/root/LookAround_files/three.min.js", new string[0]
         },
     });
 }
コード例 #9
0
 public Dictionary <string, string[]> BuildTree(ReferenceTable table, string root)
 {
     return(new TreeBuilder().BuildTree(table, root));
 }
コード例 #10
0
ファイル: GraphHelper.cs プロジェクト: Nangal/http2-katana
 public Dictionary<string, string[]> BuildTree(ReferenceTable table, string root)
 {
     return new TreeBuilder().BuildTree(table, root);
 }
コード例 #11
0
ファイル: PushMiddleware.cs プロジェクト: Nangal/http2-katana
 public PushMiddleware(OwinMiddleware next)
     : base(next)
 {
     _references = new ReferenceTable(new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase)
         {
             {
                 "/root/index.html", new[]
                     {
                         "/root/simpleTest.txt"
                     }
             },
             {
                 "/root/simpleTest.txt", new string[0]
             },
             {
                 "/root/LookAround.htm", new []
                     {
                         "/root/LookAround_files/BaseStyles.css",
                         "/root/LookAround_files/Demo.css",
                         "/root/LookAround_files/DemoTemplate.css",
                         "/root/LookAround_files/FavIcon.ico",
                         "/root/LookAround_files/ie-logo.png",
                         "/root/LookAround_files/instructions.png",
                         "/root/LookAround_files/loading.gif",
                         "/root/LookAround_files/negx.jpg",
                         "/root/LookAround_files/negy.jpg",
                         "/root/LookAround_files/negz.jpg",
                         "/root/LookAround_files/posx.jpg",
                         "/root/LookAround_files/posy.jpg",
                         "/root/LookAround_files/posz.jpg",
                         "/root/LookAround_files/ReturnAndShareControls.css",
                         "/root/LookAround_files/ReturnAndShareControls.js",
                         "/root/LookAround_files/ReturnButtonImageStrip.png",
                         "/root/LookAround_files/TestDriveCommon.js",
                         "/root/LookAround_files/three.min.js",
                     }
             },
             {
                 "/root/LookAround_files/BaseStyles.css", new string[0]
             },
             {
                 "/root/LookAround_files/Demo.css", new string[0]
             },
             {
                 "/root/LookAround_files/DemoTemplate.css", new string[0]
             },
             {
                 "/root/LookAround_files/FavIcon.ico", new string[0]
             },
             {
                 "/root/LookAround_files/ie-logo.png", new string[0]
             },
             {
                 "/root/LookAround_files/instructions.png", new string[0]
             },
             {
                 "/root/LookAround_files/loading.gif", new string[0]
             },
             {
                 "/root/LookAround_files/negx.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/negy.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/negz.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/posx.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/posy.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/posz.jpg", new string[0]
             },
             {
                 "/root/LookAround_files/ReturnAndShareControls.css", new string[0]
             },
             {
                 "/root/LookAround_files/ReturnAndShareControls.js", new string[0]
             },
             {
                 "/root/LookAround_files/ReturnButtonImageStrip.png", new string[0]
             },
             {
                 "/root/LookAround_files/TestDriveCommon.js", new string[0]
             },
             {
                 "/root/LookAround_files/three.min.js", new string[0]
             },
         });
 }
コード例 #12
0
ファイル: PushMiddleware.cs プロジェクト: Nangal/http2-katana
        public override async Task Invoke(IOwinContext context)
        {
            var isPushEnabled = context.Get<bool>(CommonOwinKeys.EnableServerPush);

            //If push is not allowed then pass to then next layer
            if (!isPushEnabled)
            {
                await Next.Invoke(context);
                return;
            }

            bool gotError = false;
            var refTree = context.Get<Dictionary<string, string[]>>(CommonOwinKeys.AdditionalInfo);
            //original request from client
            if (refTree == null)
            {
                string root = context.Request.Path.Value;
                if (!_references.ContainsKey(root))
                {
                    gotError = true; // Cant build tree because no such name in the ref table. Should invoke next
                }
                else
                {
                    var refCpy = new ReferenceTable(_references);
                    var tree = new GraphHelper().BuildTree(refCpy, root);
                    refTree = tree;
                    context.Set(CommonOwinKeys.AdditionalInfo, tree);
                }
            }
            if (!gotError)
            {
                PushFunc pushPromise;
                string[] pushReferences;

                if (refTree.TryGetValue(context.Request.Path.Value, out pushReferences)
                    && TryGetPushPromise(context, out pushPromise))
                {
                    foreach (var pushReference in pushReferences)
                    {
                        Push(context.Request, pushPromise, pushReference);
                    }
                }
            }

            context.Set(CommonOwinKeys.AddVertex, new AddVertFunc(AddVertex));
            context.Set(CommonOwinKeys.RemoveVertex, new RemoveVertFunc(RemoveVertex));

            await Next.Invoke(context);
        }