Пример #1
0
        public SelfHostRequestData(RouteData routeData, HttpRequestMessage request, ICookies cookies)
        {
            AddValues(new RouteDataValues(routeData));



            var querystring = request.RequestUri.ParseQueryString();

            AddValues("Querystring", new NamedKeyValues(querystring));

            var formData = request.Content.IsFormData() ? request.Content.ReadAsFormDataAsync().Result : new NameValueCollection();

            AddValues(RequestDataSource.Request.ToString(), new NamedKeyValues(formData));

            var headers = AggregateKeyValues.For(new HeaderKeyValues(request.Headers),
                                                 new HeaderKeyValues(request.Content.Headers));

            AddValues(RequestDataSource.Header.ToString(), headers);

            Func <string, IEnumerable <string>, bool> ignoreCaseKeyFinder = (key, keys) => keys.Contains(key, StringComparer.InvariantCultureIgnoreCase);
            var values      = new SimpleKeyValues(key => cookies.Get(key).Value, () => cookies.Request.Select(x => x.Name), ignoreCaseKeyFinder);
            var valueSource = new FlatValueSource <object>(values, RequestDataSource.Cookie.ToString());

            AddValues(valueSource);
        }
Пример #2
0
        public SelfHostRequestData(RouteData routeData, HttpRequestMessage request)
        {
            AddValues(new RouteDataValues(routeData));



            var querystring = request.RequestUri.ParseQueryString();

            AddValues("Querystring", new NamedKeyValues(querystring));

            var formData = request.Content.IsFormData() ? request.Content.ReadAsFormDataAsync().Result : new NameValueCollection();

            AddValues(RequestDataSource.Request.ToString(), new NamedKeyValues(formData));

            var headers = AggregateKeyValues.For(new HeaderKeyValues(request.Headers),
                                                 new HeaderKeyValues(request.Content.Headers));

            AddValues(RequestDataSource.Header.ToString(), headers);
        }