예제 #1
0
        internal static void SetFlash(OutputProcessor sessionHolder, string sessionID, string messageID, string value)
        {
            SessionProvider session;

            if (!sessionHolder.Sessions.TryGetValue(sessionID, out session))
            {
                session = new SessionProvider();
                sessionHolder.Sessions[sessionID] = session;
            }

            session._flashFlip[messageID] = value;
        }
예제 #2
0
        internal static void SetData(OutputProcessor sessionHolder, string sessionID, object data)
        {
            SessionProvider session;

            if (!sessionHolder.Sessions.TryGetValue(sessionID, out session))
            {
                session = new SessionProvider();
                sessionHolder.Sessions[sessionID] = session;
            }

            session.setData(data);
        }
예제 #3
0
        protected T Session <T>(Func <T> dataFactory)
        {
            var data = SessionProvider.GetData <T>(Unit.Output, Client.SessionID);

            if (object.Equals(data, default(T)))
            {
                data = dataFactory();
                if (object.Equals(data, default(T)))
                {
                    throw new NotImplementedException("Unsupported Session data value");
                }

                SessionProvider.SetData(Unit.Output, Client.SessionID, data);
            }

            return(data);
        }
예제 #4
0
        /// <summary>
        /// Callback for on head completed event
        /// </summary>
        /// <param name="client">Client which head has been downloaded</param>
        private void _onHeadCompleted(Client client, byte[] data, int dataOffset, int dataLength)
        {
            Log.Trace("HttpServer._onHeadCompleted {0}", client);


            //TODO selecting processor according to session data
            client.SetUnit(Unit);
            client.Response = new Response(client);
            SessionProvider.PrepareSessionID(client);

            //resolve IP address accordingly forward headers
            string ipValue;
            var    defaultIP = client.IP != null?client.IP.ToString() : "none";

            client.Request.TryGetHeader(HttpRequest.ForwardedHeader, out ipValue, defaultIP);
            client.Request.SetHeader(HttpRequest.IPHeader, ipValue);

            if (client.Request.ContentLength > 0)
            {
                //Send to input processor
                var inputController = _inputManager.CreateController(client);
                if (inputController == null)
                {
                    //there is no input controller for client
                    _onContentCompleted(client);
                    return;
                }

                client.Input = inputController;
                inputController.AcceptData(data, dataOffset, dataLength);

                if (inputController.ContinueDownloading)
                {
                    _downloader.DownloadContent(client);
                }
                else
                {
                    _onContentCompleted(client);
                }
            }
            else
            {
                //Send to response processor
                _onRequestCompleted(client);
            }
        }
예제 #5
0
파일: Response.cs 프로젝트: m9ra/ServeRick
 /// <summary>
 /// Get flash value for given messageID.
 /// </summary>
 /// <param name="messageID">ID of flash message</param>
 /// <returns>Flash message if present, null otherwise</returns>
 public string Flash(string messageID)
 {
     return(SessionProvider.GetFlash(Client.Unit.Output, Client.SessionID, messageID));
 }
예제 #6
0
 /// <summary>
 /// Get flash value for given messageID.
 /// </summary>
 /// <param name="messageID">ID of flash message</param>
 /// <returns>Flash message if present, null otherwise</returns>
 protected string Flash(string messageID)
 {
     return(SessionProvider.GetFlash(Unit.Output, Client.SessionID, messageID));
 }
예제 #7
0
 /// <summary>
 /// Set value to given flash type. Flash is one display durability session data.
 /// </summary>
 /// <param name="messageID">ID of flash that will be set</param>
 /// <param name="value">Value of message that will be set</param>
 protected void Flash(string messageID, string value)
 {
     SessionProvider.SetFlash(Unit.Output, Client.SessionID, messageID, value);
 }
예제 #8
0
 protected void RemoveSession <T>()
 {
     SessionProvider.RemoveData <T>(Unit.Output, Client.SessionID);
 }
예제 #9
0
 protected T Session <T>(T data)
 {
     SessionProvider.SetData(Unit.Output, Client.SessionID, data);
     return(data);
 }
예제 #10
0
 protected T Session <T>()
 {
     return(SessionProvider.GetData <T>(Unit.Output, Client.SessionID));
 }
예제 #11
0
 protected void InjectSession <T>(string sessionId, T data)
 {
     SessionProvider.SetData(Unit.Output, sessionId, data);
 }