Beispiel #1
0
        public Task <IDictionary <string, string> > ReadFormAsync()
        {
            if (!HasFormData && !HasParseableData)
            {
                return(TaskHelpers.FromResult(ParamDictionary.Parse("")));
            }

            var form      = Environment.Get <IDictionary <string, string> >("Gate.Request.Form");
            var thisInput = Body;
            var lastInput = Environment.Get <object>("Gate.Request.Form#input");

            if (form != null && ReferenceEquals(thisInput, lastInput))
            {
                return(TaskHelpers.FromResult(form));
            }

            Request thisRequest = this;

            return(ReadTextAsync().Then(text =>
            {
                form = ParamDictionary.Parse(text);
                thisRequest.Environment.Set("Gate.Request.Form#input", thisInput);
                thisRequest.Environment.Set("Gate.Request.Form", form);
                return form;
            }));
        }
Beispiel #2
0
        public IDictionary <string, string> ReadForm()
        {
            if (!HasFormData && !HasParseableData)
            {
                return(ParamDictionary.Parse(""));
            }

            var form      = Environment.Get <IDictionary <string, string> >("Gate.Request.Form");
            var thisInput = Body;
            var lastInput = Environment.Get <object>("Gate.Request.Form#input");

            if (form != null && ReferenceEquals(thisInput, lastInput))
            {
                return(form);
            }

            var text = ReadText();

            form = ParamDictionary.Parse(text);
            Environment.Set("Gate.Request.Form#input", thisInput);
            Environment.Set("Gate.Request.Form", form);
            return(form);
        }