Ejemplo n.º 1
0
        public override void TransitionToState( ISessionContext context )
        {
            Contract.Requires( context.ClientConnection != null );
            Contract.Requires( context.ServerConnection == null );

            context.SendClientData(Encoding.UTF8.GetBytes("HTTPS not supported"));
            context.Reset();

            //// TODO: is this required?
            //context.ClientConnection.CancelPendingReceive();
            //context.UnwireClientParserEvents();

            //ServiceLog.Logger.Info( "{0} Establishing HTTPS tunnel", context.Id );

            //string[] pathTokens = context.RecentRequestHeader.Path.Split( ':' );

            //if ( pathTokens.Length == 2 )
            //{
            //    context.ConnectToRemoteHost( pathTokens[0], Int32.Parse( pathTokens[1] ) );
            //}
            //else
            //{
            //    throw new InvalidDataException( "Unable to determine SSL host address" );
            //}

            //_context = context;
        }
Ejemplo n.º 2
0
        public override void AcknowledgeClientShutdown(ISessionContext context)
        {
            ServiceLog.Logger.Verbose("{0} ACK client shutdown.", context.Id);

            // Shutdown the connection if there are no active transactions
            if (context.HttpPipelineDepth == 0)
            {
                context.Reset();
            }
        }
Ejemplo n.º 3
0
        public override void TransitionToState(ISessionContext context)
        {
            //context.UnwireClientParserEvents();

            if (context.ClientConnection != null)
            {
                context.SendClientData(Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\nContent-length: 11\r\n\r\nProxy error"));
            }

            context.Reset();
        }
Ejemplo n.º 4
0
        public override void TransitionToState(ISessionContext context)
        {
            context.CloseServerConnection();

            if (context.RecentRequestHeader.IsSsl)
            {
                context.ChangeState(SessionStateType.Https);
            }
            else
            {
                string host;
                int port;

                if (SessionStateUtils.TryParseAddress(context.RecentRequestHeader, out host, out port))
                {
                    context.BeginConnectToRemoteHost(host, port);
                }
                else
                {
                    ServiceLog.Logger.Error("{0} Unable to parse host address: {1}", context.Id, Encoding.UTF8.GetString(context.RecentRequestHeader.GetBuffer()));
                    context.Reset();
                }
            }
        }
Ejemplo n.º 5
0
        public override void SentFullServerResponseToClient( IHttpResponse response, ISessionContext context )
        {
            ServiceLog.Logger.Verbose("{0} Evaluating persistent connection. Pipeline: {1}  Client shutdown: {2}  ServerShutdown: {3}", context.Id, context.HttpPipelineDepth, context.HasClientBegunShutdown, context.HasServerBegunShutdown);

            if ( !response.IsPersistent || (context.HttpPipelineDepth == 0 && ( context.HasClientBegunShutdown || context.HasServerBegunShutdown ) ) )
            {
                ServiceLog.Logger.Info("{0} Non-persistent connection. Closing session.", context.Id);
                context.Reset();
            }
            else
            {
                ServiceLog.Logger.Info("{0} Maintaining persistent connection.", context.Id);
            }
        }
Ejemplo n.º 6
0
 public virtual void ServerConnectionLost( ISessionContext context )
 {
     context.Reset();
 }
Ejemplo n.º 7
0
 public virtual void AcknowledgeServerShutdown( ISessionContext context )
 {
     ServiceLog.Logger.Info("{0} SessionStateBase::AcknowledgeServerShutdown", context.Id);
     context.Reset();
 }
Ejemplo n.º 8
0
 public override void TransitionToState( ISessionContext context )
 {
     context.Reset();
 }
Ejemplo n.º 9
0
 public override void ServerConnectionLost( ISessionContext context )
 {
     ServiceLog.Logger.Info( "{0} HTTPS connection lost", context.Id );
     context.Reset();
 }