public Tuple<IEnumerable<string>, IEnumerable<string>> Get()
        {
            HttpConfiguration configuration = new HttpConfiguration();
            configuration.MessageHandlers.Add(new FooHandler());          //利用HttpConfiguration注册3个自定义的DelegatingHandler
            configuration.MessageHandlers.Add(new BarHandler());
            configuration.MessageHandlers.Add(new BazHandler());

            MyHttpServer httpServer = new MyHttpServer(configuration);       //创建自定义的HttpServer
            IEnumerable<string> chain1 = this.GetHandlerChain(httpServer).ToArray();
            httpServer.Initialize();                             //调用HttpServer的Initialize方法,从而初始化整个消息处理管道
            IEnumerable<string> chain2 = this.GetHandlerChain(httpServer).ToArray();
            return new Tuple<IEnumerable<string>, IEnumerable<string>>(chain1, chain2);     //两个字符串集合组成一个Tuple<IEnumerable<string>, IEnumerable<string>>对象并将其作为Get方法的返回值,这个Tuple反映了HttpMessageHandler链在HttpServer初始化前后的结构
        }
Example #2
0
        public Tuple <IEnumerable <string>, IEnumerable <string> > Get()
        {
            HttpConfiguration configuration = new HttpConfiguration();

            configuration.MessageHandlers.Add(new FooHandler());          //利用HttpConfiguration注册3个自定义的DelegatingHandler
            configuration.MessageHandlers.Add(new BarHandler());
            configuration.MessageHandlers.Add(new BazHandler());

            MyHttpServer         httpServer = new MyHttpServer(configuration); //创建自定义的HttpServer
            IEnumerable <string> chain1     = this.GetHandlerChain(httpServer).ToArray();

            httpServer.Initialize();                             //调用HttpServer的Initialize方法,从而初始化整个消息处理管道
            IEnumerable <string> chain2 = this.GetHandlerChain(httpServer).ToArray();

            return(new Tuple <IEnumerable <string>, IEnumerable <string> >(chain1, chain2));     //两个字符串集合组成一个Tuple<IEnumerable<string>, IEnumerable<string>>对象并将其作为Get方法的返回值,这个Tuple反映了HttpMessageHandler链在HttpServer初始化前后的结构
        }
Example #3
0
        public Tuple <IEnumerable <string>, IEnumerable <string> > ServerTest()
        {
            HttpConfiguration config = new HttpConfiguration();

            config.MessageHandlers.Add(new FooHandler());
            config.MessageHandlers.Add(new BarHandler());
            config.MessageHandlers.Add(new BazHandler());

            MyHttpServer httpserver = new MyHttpServer(config);
            var          chain1     = GetHandleChain(httpserver).ToArray();

            httpserver.Initialize();
            var chain2 = GetHandleChain(httpserver).ToArray();

            return(new Tuple <IEnumerable <string>, IEnumerable <string> >(chain1, chain2));
        }
Example #4
0
        public Tuple <IEnumerable <string>, IEnumerable <string> > Get()
        {
            HttpConfiguration configuration = new HttpConfiguration();

            configuration.MessageHandlers.Add(new FooHandler());
            configuration.MessageHandlers.Add(new BarHandler());
            configuration.MessageHandlers.Add(new BazHandler());

            MyHttpServer         httpServer = new MyHttpServer(configuration);
            IEnumerable <string> chain1     = this.GetHandlerChain(httpServer).ToArray();

            httpServer.Initialize();
            IEnumerable <string> chain2 = this.GetHandlerChain(httpServer).ToArray();

            return(new Tuple <IEnumerable <string>, IEnumerable <string> >(chain1, chain2));
        }