示例#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);
        }
示例#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);
        }
示例#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;
            }));
        }
示例#4
0
 public Request()
     : this(new Dictionary <string, object>())
 {
     Environment.Set(OwinConstants.RequestHeaders, Gate.Headers.New());
     Environment.Set(OwinConstants.ResponseHeaders, Gate.Headers.New());
 }