Add() публичный Метод

Adds the specified child T:Stumps.Http.IHttpHandler to the end of the pipeline.
public Add ( IHttpHandler handler ) : void
handler IHttpHandler The child to add.
Результат void
Пример #1
0
        public void AddHandler_AcceptsMultipleHandlers()
        {
            var pipe = new HttpPipelineHandler();

            Assert.AreEqual(0, pipe.Count);

            pipe.Add(Substitute.For <IHttpHandler>());
            pipe.Add(Substitute.For <IHttpHandler>());
            Assert.AreEqual(2, pipe.Count);
        }
Пример #2
0
        public void AddHandler_AcceptsMultipleHandlers()
        {

            var pipe = new HttpPipelineHandler();
            Assert.AreEqual(0, pipe.Count);

            pipe.Add(Substitute.For<IHttpHandler>());
            pipe.Add(Substitute.For<IHttpHandler>());
            Assert.AreEqual(2, pipe.Count);

        }
Пример #3
0
        public async Task ProcessRequest_StopsExecutingWhenTerminateReturned()
        {
            var context       = Substitute.For <IStumpsHttpContext>();
            var pipe          = new HttpPipelineHandler();
            var innerHandler1 = new NoOpHandler(ProcessHandlerResult.Terminate);
            var innerHandler2 = new NoOpHandler(ProcessHandlerResult.Continue);

            pipe.Add(innerHandler1);
            pipe.Add(innerHandler2);

            var result = await pipe.ProcessRequest(context);

            Assert.AreEqual(ProcessHandlerResult.Terminate, result, "The process request returned a Continue.");
            Assert.AreEqual(1, innerHandler1.ProcessRequestCalls());
            Assert.AreEqual(0, innerHandler2.ProcessRequestCalls());
        }
Пример #4
0
        public async void ProcessRequest_StopsExecutingWhenTerminateReturned()
        {

            var context = Substitute.For<IStumpsHttpContext>();
            var pipe = new HttpPipelineHandler();
            var innerHandler1 = new NoOpHandler(ProcessHandlerResult.Terminate);
            var innerHandler2 = new NoOpHandler(ProcessHandlerResult.Continue);

            pipe.Add(innerHandler1);
            pipe.Add(innerHandler2);

            var result = await pipe.ProcessRequest(context);

            Assert.AreEqual(ProcessHandlerResult.Terminate, result, "The process request returned a Continue.");
            Assert.AreEqual(1, innerHandler1.ProcessRequestCalls());
            Assert.AreEqual(0, innerHandler2.ProcessRequestCalls());

        }
Пример #5
0
        public void Indexer_ReturnsItem()
        {
            var pipe = new HttpPipelineHandler();

            var handler1 = new MockHandler()
            {
                HandlerId = 1
            };

            var handler2 = new MockHandler()
            {
                HandlerId = 2
            };

            pipe.Add(handler1);
            pipe.Add(handler2);

            Assert.AreEqual(1, ((MockHandler)pipe[0]).HandlerId);
            Assert.AreEqual(2, ((MockHandler)pipe[1]).HandlerId);
        }
Пример #6
0
        public void Indexer_ReturnsItem()
        {

            var pipe = new HttpPipelineHandler();
            
            var handler1 = new MockHandler()
            {
                HandlerId = 1
            };
            
            var handler2 = new MockHandler()
            {
                HandlerId = 2
            };

            pipe.Add(handler1);
            pipe.Add(handler2);

            Assert.AreEqual(1, ((MockHandler)pipe[0]).HandlerId);
            Assert.AreEqual(2, ((MockHandler)pipe[1]).HandlerId);

        }
Пример #7
0
        /// <summary>
        ///     Starts this instance of the Stumps server.
        /// </summary>
        public void Start()
        {
            lock (_syncRoot)
            {

                if (_started)
                {
                    return;
                }

                _started = true;

                // Setup the pipeline HTTP handler
                var pipeline = new HttpPipelineHandler();

                // Setup the Stump HTTP handler
                _stumpsHandler = new StumpsHandler(_stumpsManager);
                _stumpsHandler.Enabled = this.StumpsEnabled;

                pipeline.Add(_stumpsHandler);

                // Setup the Proxy HTTP handler
                if (_remoteHttpServer != null)
                {
                    var proxyHandler = new ProxyHandler(_remoteHttpServer);
                    pipeline.Add(proxyHandler);
                }
                else
                {
                    // Setup the Service Unavailable HTTP handler
                    var stumpNotFoundHandler = new FallbackResponseHandler(_defaultResponse);
                    pipeline.Add(stumpNotFoundHandler);
                }

                var scheme = _useHttpsForIncommingConnections ? ServerScheme.Https : ServerScheme.Http;
                _server = new HttpServer(scheme, _port, pipeline);

                _server.RequestFinished += ServerRequestFinished;
                _server.RequestProcessed += ServerRequestProcessed;
                _server.RequestReceived += ServerRequestStarted;

                _server.StartListening();

            }
        }