Exemplo n.º 1
0
        /// <summary>
        ///     Creates new instance of <see cref="HttpProxy" /> using provided default port and internal buffer size.
        /// </summary>
        /// <param name="defaultPort">
        ///     Port number on destination server which will be used if not specified in request
        /// </param>
        public HttpProxy(Int32 defaultPort)
        {
            Contract.Requires <ArgumentOutOfRangeException>(
                defaultPort > IPEndPoint.MinPort &&
                defaultPort < IPEndPoint.MaxPort, "defaultPort"
                );

            _defaultPort = defaultPort;

            ClientReadTimeout  = DefaultCommunicationTimeout;
            ClientWriteTimeout = DefaultCommunicationTimeout;
            ServerReadTimeout  = DefaultCommunicationTimeout;
            ServerWriteTimeout = DefaultCommunicationTimeout;

            _pipeline = new ProcessingPipeline(new Dictionary <ProcessingStage, Action <ProcessingContext> >
            {
                { ProcessingStage.ReceiveRequest, ReceiveRequest + _onRequestReceivedWrapper },
                { ProcessingStage.ConnectToServer, ConnectToServer + _onServerConnectedWrapper },
                { ProcessingStage.ReceiveResponse, ReceiveResponse + _onResponseReceivedWrapper },
                { ProcessingStage.Completed, CompleteProcessing + _onProcessingCompleteWrapper },
                { ProcessingStage.SendResponse, SendResponse + _onResponseSentWrapper }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates new instance of <see cref="HttpProxy" /> using provided default port and internal buffer size.
        /// </summary>
        /// <param name="defaultPort">
        ///     Port number on destination server which will be used if not specified in request
        /// </param>
        public HttpProxy(Int32 defaultPort)
        {
            Contract.Requires<ArgumentOutOfRangeException>(
                defaultPort > IPEndPoint.MinPort
                && defaultPort < IPEndPoint.MaxPort, "defaultPort"
            );

            _defaultPort = defaultPort;

            ClientReadTimeout = DefaultCommunicationTimeout;
            ClientWriteTimeout = DefaultCommunicationTimeout;
            ServerReadTimeout = DefaultCommunicationTimeout;
            ServerWriteTimeout = DefaultCommunicationTimeout;

            _pipeline = new ProcessingPipeline(new Dictionary<ProcessingStage, Action<ProcessingContext>>
            {
                {ProcessingStage.ReceiveRequest, ReceiveRequest + _onRequestReceivedWrapper},
                {ProcessingStage.ConnectToServer, ConnectToServer + _onServerConnectedWrapper},
                {ProcessingStage.ReceiveResponse, ReceiveResponse + _onResponseReceivedWrapper},
                {ProcessingStage.Completed, CompleteProcessing + _onProcessingCompleteWrapper},
                {ProcessingStage.SendResponse, SendResponse + _onResponseSentWrapper}
            });
        }