Beispiel #1
0
        public string ReadText()
        {
            var text = Environment.Get <string>("Gate.Request.Text");

            var thisInput = Body;
            var lastInput = Environment.Get <object>("Gate.Request.Text#input");

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

            if (thisInput != null)
            {
                if (thisInput.CanSeek)
                {
                    thisInput.Seek(0, SeekOrigin.Begin);
                }
                text = new StreamReader(thisInput).ReadToEnd();
            }

            Environment.Set("Gate.Request.Text#input", thisInput);
            Environment.Set("Gate.Request.Text", text);
            return(text);
        }
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);
        }
Beispiel #3
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));
            }

            return(ReadTextAsync().Then(text =>
            {
                form = ParamDictionary.Parse(text);
                Environment.Set("Gate.Request.Form#input", thisInput);
                Environment.Set("Gate.Request.Form", form);
                return form;
            }));
        }
Beispiel #4
0
 public Request()
     : this(new Dictionary <string, object>())
 {
     Environment.Set(OwinConstants.RequestHeaders, Gate.Headers.New());
     Environment.Set(OwinConstants.ResponseHeaders, Gate.Headers.New());
 }