A class implementing the T:Stumps.Http.IHttpHandler interface that proxies requests to an external host.
Inheritance: IHttpHandler
示例#1
0
        public void ProcessRequest_NullValue_ThrowsException()
        {
            var proxy = new ProxyHandler(new Uri("http://localhost/"));

            Assert.That(
                async () => await proxy.ProcessRequest(null),
                Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("context"));
        }
示例#2
0
        public void ProcessRequest_NullValue_ThrowsException()
        {
            var proxy = new ProxyHandler(new Uri("http://localhost/"));

            Assert.That(
                async() => await proxy.ProcessRequest(null),
                Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("context"));
        }
示例#3
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();

            }
        }