public static Uri GetNavigationUri(TodoListModel todoList)
 {
     HttpValueCollection httpValues = new HttpValueCollection();
     httpValues.Add(TodoListTitle, todoList.Title);
     httpValues.Add(TodoListId, todoList.TodoListId.ToString());
     return new Uri("/EditTodoListPage.xaml?" + httpValues.ToString(), UriKind.Relative);
 }
        static string GetAccessTokenFromFragment(Uri uri)
        {
            HttpValueCollection httpValues = uri.ParseFragment();

            string[] accessTokens = httpValues.GetValues("access_token");
            return(accessTokens.Length > 0 ? accessTokens[0] : null);
        }
        public void Create_InitializesCorrectly(IEnumerable <KeyValuePair <string, string> > input)
        {
            var nvc = HttpValueCollection.Create(input);

            int count = input.Count();

            Assert.IsType <HttpValueCollection>(nvc);
            Assert.Equal(count, nvc.Count);

            int index = 0;

            foreach (KeyValuePair <string, string> kvp in input)
            {
                string expectedKey   = kvp.Key ?? String.Empty;
                string expectedValue = kvp.Value ?? String.Empty;

#if NETFX_CORE
                KeyValuePair <string, string> actualKvp = nvc.List[index];
                string actualKey   = actualKvp.Key;
                string actualValue = actualKvp.Value;
#else
                string actualKey   = nvc.AllKeys[index];
                string actualValue = nvc[index];
#endif
                index++;

                Assert.Equal(expectedKey, actualKey);
                Assert.Equal(expectedValue, actualValue);
            }
        }
Пример #4
0
        public Uri GetAuthorizationUri(
            string oauthToken,
            Uri authorizeUri)
        {
            if (authorizeUri == null)
            {
                throw new ArgumentNullException(nameof(authorizeUri));
            }

            if (string.IsNullOrEmpty(oauthToken))
            {
                throw new ArgumentNullException(nameof(oauthToken));
            }

            var builder = new UriBuilder(authorizeUri.NonPath());

            builder.Path += authorizeUri.AbsolutePath.TrimStart('/');

            var query = new HttpValueCollection
            {
                { OAuth2ParameterEnum.OAuthToken.EnumToString(), oauthToken }
            };

            builder.Query += query.ToString();

            return(builder.Uri);
        }
Пример #5
0
        //public UrlBuilder(string url)
        //{
        //}
        public UrlBuilder(string url)
        {
            if (url == null)
            throw new ArgumentNullException("url");

              int targetStartPosition = url.IndexOf('#');

              // question mark found
              if (targetStartPosition != -1)
              {
            string target = url.Substring(targetStartPosition + 1, url.Length - targetStartPosition - 1);

            _target = HttpUtility.UrlDecode(target);
              }

              int queryStartPosition = url.IndexOf('?');

              // question mark found
              if (queryStartPosition != -1)
              {
            // get querystring and url without querystring
            string queryString = url.Substring(queryStartPosition + 1, url.Length - queryStartPosition - 1);
            url = url.Substring(0, queryStartPosition);

            _queryString = new HttpValueCollection(queryString, true, Encoding.UTF8);
              }

              _path = HttpUtility.UrlDecode(url);
        }
        public void Create_CreatesEmptyCollection()
        {
            NameValueCollection nvc = HttpValueCollection.Create();

            Assert.IsType <HttpValueCollection>(nvc);
            Assert.Equal(0, nvc.Count);
        }
 public static Uri GetNavigationUri(Account account)
 {
     HttpValueCollection httpValues = new HttpValueCollection();
     httpValues.Add(AccountName, account.Provider);
     httpValues.Add(Username, account.ProviderKey);
     return new Uri("/AccountDetailsPage.xaml?" + httpValues.ToString(), UriKind.Relative);
 }
Пример #8
0
        public void Register_InvalidPassword_Fails()
        {
            string invalidPassword = "******";
            var formData = new HttpValueCollection {
                {"UserName", "Bill"},
                {"Email", "*****@*****.**"},
                {"Password", invalidPassword},
                {"ConfirmPassword", invalidPassword}
            };

            using (var scope = new MvcExecutorScope(new ExecutorSettings("Account/Register") { Form = formData }))
            {
                var responseText = scope.ResponseText;

                Assert.IsFalse(scope.ViewData.ModelState.IsValid);

                var errors = new List<string>();
                foreach (var modelState in scope.ViewData.ModelState.Values)
                    errors.AddRange(modelState.Errors.Select<ModelError, string>(e => e.ErrorMessage));

                Assert.AreEqual(1, errors.Count);

                string passwordError = "The Password must be at least 6 characters long.";
                Assert.AreEqual(passwordError, errors[0]);

                var html = new HtmlDocument();
                html.LoadHtml(scope.ResponseText);

                var passwordErrorSpan = html.DocumentNode.CssSelect("span.field-validation-error");
                Assert.AreEqual(1, passwordErrorSpan.Count());
                Assert.AreEqual(passwordError, passwordErrorSpan.ElementAt(0).InnerText);
            }
        }
Пример #9
0
        public static TEntity AsEntity <TEntity>(
            this HttpValueCollection source,
            bool withType = true)
        {
            var dictionary = source
                             .ToDictionary <HttpValue, string, object>(
                value => value.Key,
                value => value.Value);

            if (withType)
            {
                var rootType        = typeof(TEntity);
                var typedDictionary = new Dictionary <string, object>
                {
                    { "$type", $"{rootType.FullName}, {rootType.GetTypeInfo().Assembly.GetName().Name}" }
                };
                foreach (var item in dictionary)
                {
                    typedDictionary.Add(item.Key, item.Value);
                }
                dictionary = typedDictionary;
            }

            return(dictionary.AsEntity <TEntity>(true));
        }
        public static Uri GetNavigationUri(int todoListId)
        {
            HttpValueCollection values = new HttpValueCollection();

            values.Add(TodoListId, todoListId.ToString());
            return(new Uri("/AddTodoItemPage.xaml?" + values.ToString(), UriKind.Relative));
        }
Пример #11
0
        public void Test_HttpValueCollection()
        {
            HttpValueCollection collection = new HttpValueCollection();

            int count = 0;

            collection.MakeReadOnly();

            try {
                collection.Add("k1", "abc");
            }
            catch (NotSupportedException) {
                count++;
            }

            collection.MakeReadWrite();

            try {
                collection.Add("k1", "abc");
            }
            catch (NotSupportedException) {
                count++;
            }

            Assert.AreEqual(1, count);
        }
        private static string BuildQueryString(object queryParams, bool lowerCaseQueryKeys)
        {
            if (queryParams == null)
            {
                return(string.Empty);
            }

            var dict = queryParams.ToDictionary();

            if (dict.Count == 0)
            {
                return(string.Empty);
            }

            var queryCollection = new HttpValueCollection();

            foreach (var item in dict)
            {
                if (item.Value == null)
                {
                    continue;
                }

                queryCollection[lowerCaseQueryKeys ? item.Key.ToLower() : item.Key] = item.Value.ToString();
            }
            return(queryCollection.ToString());
        }
        public static Uri GetNavigationUri(TodoListModel todoList)
        {
            HttpValueCollection httpValues = new HttpValueCollection();

            httpValues.Add(TodoListTitle, todoList.Title);
            httpValues.Add(TodoListId, todoList.TodoListId.ToString());
            return(new Uri("/EditTodoListPage.xaml?" + httpValues.ToString(), UriKind.Relative));
        }
 public static Uri GetNavigationUri(string provider, string username, string externalLoginUri)
 {
     HttpValueCollection httpValues = new HttpValueCollection();
     httpValues.Add(Provider, provider);
     httpValues.Add(Username, username);
     httpValues.Add(ExternalLoginUri, externalLoginUri);
     return new Uri("/RegisterExternalPage.xaml?" + httpValues.ToString(), UriKind.Relative);
 }
        private static HttpValueCollection CreateInstance()
        {
#if NETFX_CORE
            return(new HttpValueCollection());
#else
            return(HttpValueCollection.Create());
#endif
        }
Пример #16
0
        public static Uri GetNavigationUri(Account account)
        {
            HttpValueCollection httpValues = new HttpValueCollection();

            httpValues.Add(AccountName, account.Provider);
            httpValues.Add(Username, account.ProviderKey);
            return(new Uri("/AccountDetailsPage.xaml?" + httpValues.ToString(), UriKind.Relative));
        }
        /// <summary>
        /// Creates an HttpValueCollection with the common parameters for each auth method - namely the client keys.
        /// </summary>
        /// <param name="clientId">The id of the application.</param>
        /// <param name="clientSecret">The application's secret.</param>
        /// <returns>An HttpValueCollection populated with these values.</returns>
        private static HttpValueCollection GetBasicParameters(string clientId, string clientSecret)
        {
            var parameters = new HttpValueCollection();

            parameters.Add("client_id", clientId);
            parameters.Add("client_secret", clientSecret);
            return(parameters);
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReBugContext"/> class.
        /// </summary>
        /// <param name="bug">The bug.</param>
        protected ReBugContext(IXPathNavigable bug)
        {
            XPathNavigator xml = bug.CreateNavigator();
            _QueryString = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/queryString"));

            _Form = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/form"));

            XPathNavigator cookie = xml.SelectSingleNode("/bugx/headers/Cookie");
            if (cookie != null)
            {
                _Cookies = HttpValueCollection.CreateCollectionFromCookieHeader(cookie.Value);
            }
            _Headers = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/headers"));

            _Session = FillNameValue(xml.Select("/bugx/sessionVariables/add"));
            _Cache = FillNameValue(xml.Select("/bugx/cacheVariables/add"));
            _Application = FillNameValue(xml.Select("/bugx/applicationVariables/add"));
            _Context = FillHashtable(xml.Select("/bugx/contextVariables/add"));

            XPathNavigator exception = xml.SelectSingleNode("/bugx/exception");
            if (exception != null)
            {
                try
                {
                    _Exception = (Exception)BugSerializer.Deserialize(exception.Value);
                }catch(SerializationException){}
            }
            XPathNavigator url = xml.SelectSingleNode("/bugx/url");
            if (url != null)
            {
                _Url = new Uri(url.Value);
            }
            XPathNavigator pathInfo = xml.SelectSingleNode("/bugx/pathInfo");
            if (pathInfo != null)
            {
                _PathInfo = pathInfo.Value;
            }
            XPathNavigator machineName = xml.SelectSingleNode("/bugx/machineName");
            if (machineName != null)
            {
                _MachineName = machineName.Value;
            }
            XPathNavigator scriptTimeout = xml.SelectSingleNode("/bugx/scriptTimeout");
            if (scriptTimeout != null)
            {
                _ScriptTimeout = Convert.ToInt32(scriptTimeout.Value, CultureInfo.InvariantCulture);
            }
            XPathNavigator user = xml.SelectSingleNode("/bugx/user");
            if (user != null)
            {
                try
                {
                    _User = (IPrincipal)BugSerializer.Deserialize(user.Value);
                }
                catch(SerializationException){}
                catch(TargetInvocationException){}
            }
        }
Пример #19
0
        public Uri GetAuthorizationUri(
            Uri authorizeUrl,
            string clientId,
            string scope,
            Uri redirectUri,
            string state,
            ResponseTypeEnum responseType,
            Dictionary <string, string> queryParameters)
        {
            if (authorizeUrl == null)
            {
                throw new ArgumentNullException(nameof(authorizeUrl));
            }

            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }

            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            if (redirectUri == null)
            {
                throw new ArgumentNullException(nameof(redirectUri));
            }

            if (string.IsNullOrEmpty(state))
            {
                throw new ArgumentNullException(nameof(state));
            }

            var builder = new UriBuilder(authorizeUrl.NonPath());

            builder.Path += authorizeUrl.AbsolutePath.TrimStart('/');

            var query = new HttpValueCollection
            {
                { OAuth2ParameterEnum.RedirectUri.EnumToString(), redirectUri.ToString() },
                { OAuth2ParameterEnum.ClientId.EnumToString(), clientId },
                { OAuth2ParameterEnum.Scope.EnumToString(), scope },
                { OAuth2ParameterEnum.State.EnumToString(), state },
                { OAuth2ParameterEnum.ResponseType.EnumToString(), responseType.EnumToString() }
            };

            foreach (var parameter in queryParameters)
            {
                query.Add(
                    parameter.Key,
                    parameter.Value);
            }

            builder.Query += query.ToString();

            return(builder.Uri);
        }
Пример #20
0
        public void AddParameter(string key, string value)
        {
            if (value == null)
                return;
            if (Query == null)
                Query = new HttpValueCollection();

            Query.Add(key, value);
        }
Пример #21
0
        public static Uri GetNavigationUri(string provider, string username, string externalLoginUri)
        {
            HttpValueCollection httpValues = new HttpValueCollection();

            httpValues.Add(Provider, provider);
            httpValues.Add(Username, username);
            httpValues.Add(ExternalLoginUri, externalLoginUri);
            return(new Uri("/RegisterExternalPage.xaml?" + httpValues.ToString(), UriKind.Relative));
        }
        internal void ToString_GeneratesCorrectOutput(
            HttpValueCollection input,
            string expectedOutput
            )
        {
            string actualOutput = input.ToString();

            Assert.Equal(expectedOutput, actualOutput);
        }
        internal AsyncCoinbasePageList(CoinbaseClient client, string endpoint, int?resultsPerPage, HttpValueCollection parameters, JsonConverter[] converters)
        {
            CoinbaseClient = client;
            Endpoint       = endpoint;
            ResultsPerPage = resultsPerPage;
            Parameters     = parameters;
            Converters     = converters;

            PageCache = new List <TPaginated>();
        }
Пример #24
0
        protected override Task <Dictionary <string, object> > OAuthAuthorizeAction(HttpValueCollection response)
        {
            var result = new Dictionary <string, object>();

            foreach (var kv in response)
            {
                result[kv.Key] = kv.Value;
            }
            return(Task.FromResult(result));
        }
Пример #25
0
 /// <summary>
 /// Get the collection as a NameValueCollection.
 /// Beware this loses some ordering. Values are ordered within a key,
 /// but keys are no longer ordered against each other.
 /// </summary>
 public NameValueCollection ReadAsNameValueCollection()
 {
     if (_nameValueCollection == null)
     {
         // Initialize in a private collection to be thread-safe, and swap the finished object.
         // Ok to double initialize this.
         NameValueCollection newCollection = HttpValueCollection.Create(this);
         Interlocked.Exchange(ref _nameValueCollection, newCollection);
     }
     return(_nameValueCollection);
 }
Пример #26
0
        private static string ErrorMessage(HttpValueCollection query)
        {
            var error = new StringBuilder();

            if (query != null)
            {
                foreach (var kv in query)
                {
                    error.Append(kv.Key).Append(" : ").Append(kv.Value).AppendLine();
                }
            }
            return(error.ToString());
        }
Пример #27
0
        protected virtual bool IsResponseSecure(HttpValueCollection query)
        {
            string securityValue = null;

            if (query.ContainsKey(_securityParameter))
            {
                securityValue = query[_securityParameter];
            }

            return(_securityStrategy.IsSecureParameterValid(
                       _userId,
                       _securityParameter,
                       securityValue));
        }
        public void GetIsEquivalentToIndexerProperty(IEnumerable <KeyValuePair <string, string> > input)
        {
            var nvc = HttpValueCollection.Create(input);

            int count = input.Count();

            Assert.IsType <HttpValueCollection>(nvc);
            Assert.Equal(count, nvc.Count);

            foreach (KeyValuePair <string, string> kvp in input)
            {
                Assert.Equal(nvc[kvp.Key], nvc.Get(kvp.Key));
            }
        }
        private static void Create_CreateDoesntThrowTooManyValuesPrivate()
        {
            // note this is static, but also the expected type in a real run.
            MediaTypeFormatter.MaxHttpCollectionKeys = _maxCollectionKeys;

            List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < _maxCollectionKeys + 1; i++)
            {
                list.Add(new KeyValuePair <string, string>("key", i.ToString()));
            }

            Assert.DoesNotThrow(() => HttpValueCollection.Create(list));
        }
Пример #30
0
        public void Checkout_Success()
        {
            string userName = "******";
            int numItemsInCart = 2;

            var cart = TestUtil.AddItemsToCart(userName, storeDB.Albums.Take(numItemsInCart));

            var form = new HttpValueCollection
            {
             { "FirstName","Miles"},
             {"LastName","Davis"},
             {"Address","100 Broadway Ave."},
             {"City","New York"},
             {"State","NY"},
             {"PostalCode","12345"},
             {"Country","United States"},
             {"Phone","111-111-1111"},
             {"Email","*****@*****.**"},
             {"PromoCode","FREE"}
            };

            var settings = new ExecutorSettings("Checkout/AddressAndPayment") {
                Form=form,
                HttpMethod="POST",
                User=TestUtil.CreateUser(userName)
            };

            Order order;
            using (var scope = new MvcExecutorScope(settings))
            {
                Assert.AreEqual(302, scope.HttpContext.Response.StatusCode);

                var match = new Regex("/Checkout/Complete/(\\d+)").Match(scope.HttpContext.Response.RedirectLocation);
                Assert.IsTrue(match.Success);

                var orderId = Int32.Parse(match.Groups[1].Value);

                order = storeDB.Orders.Single(o=>o.OrderId==orderId);
                Assert.AreEqual(form["FirstName"], order.FirstName);
                Assert.AreEqual(form["Email"], order.Email);

                var orderDetails = storeDB.OrderDetails.Where(od => od.OrderId == orderId);
                Assert.AreEqual(numItemsInCart, orderDetails.Count());
            }

            // Cleanup
            storeDB.Orders.Remove(order);
            storeDB.SaveChanges();
        }
Пример #31
0
        internal static HttpValueCollection Parse(string value)
        {
            if (String.IsNullOrEmpty(value)) return new HttpValueCollection();

            string[] pairs = value.Split('&');
            var coll = new HttpValueCollection(pairs.Length);
            for (var i = 0; i < pairs.Length; i++)
            {
                string[] keyValue = pairs[i].Split('=');
                if (keyValue.Length == 2)
                    coll[keyValue[0]] = HttpUtility.UrlDecode(keyValue[1]);
            }

            return coll;
        }
        private static void Create_CreateTooManyKeysThrowsPrivate()
        {
            // Arrange
            MediaTypeFormatter.MaxHttpCollectionKeys = _maxCollectionKeys;

            List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < _maxCollectionKeys + 1; i++)
            {
                list.Add(new KeyValuePair <string, string>(i.ToString(), i.ToString()));
            }

            // Act & Assert
            Assert.Throws <InvalidOperationException>(() => HttpValueCollection.Create(list), TooManyKeysError);
        }
        private static void AddDoesntThrowTooManyValuesPrivate()
        {
            // Note this is static, but also the expected type in a real run.
            MediaTypeFormatter.MaxHttpCollectionKeys = _maxCollectionKeys;

            HttpValueCollection collection = CreateInstance();

            // Act && Assert
            Assert.DoesNotThrow(() =>
            {
                for (int i = 0; i < 1001; i++)
                {
                    collection.Add("key", i.ToString());
                }
            });
        }
Пример #34
0
        private static void AddTooManyKeysThrowsPrivate()
        {
            // Note this is static, but also the expected type in a real run.
            MediaTypeFormatter.MaxHttpCollectionKeys = _maxCollectionKeys;

            HttpValueCollection collection = CreateInstance();

            for (int i = 0; i < _maxCollectionKeys; i++)
            {
                collection.Add(i.ToString(), i.ToString());
            }

            // Act && Assert
            Assert.Throws <InvalidOperationException>(
                () => collection.Add(_maxCollectionKeys.ToString(), _maxCollectionKeys.ToString()),
                TooManyKeysError);
        }
Пример #35
0
 /// <summary>
 /// Saves the request.
 /// </summary>
 /// <param name="root">The root.</param>
 /// <param name="context">The context.</param>
 static void SaveRequest(XmlNode root, HttpContext context)
 {
     if (context.Request != null)
     {
         HttpValueCollection.SaveCollectionToXmlNode(context.Request.QueryString,
                                                     root.AppendChild(root.OwnerDocument.CreateElement("queryString")));
         HttpValueCollection.SaveCollectionToXmlNode(context.Request.Form,
                                                     root.AppendChild(root.OwnerDocument.CreateElement("form")));
         HttpValueCollection.SaveCollectionToXmlNode(context.Request.Headers,
                                                     root.AppendChild(root.OwnerDocument.CreateElement("headers")));
     }
     if (context.Server != null)
     {
         root.AppendChild(root.OwnerDocument.CreateElement("machineName")).InnerText   = context.Server.MachineName;
         root.AppendChild(root.OwnerDocument.CreateElement("scriptTimeout")).InnerText = context.Server.ScriptTimeout.ToString(CultureInfo.InvariantCulture);
     }
 }
Пример #36
0
        public IDisposable RewritePath(string newVirtualPath, bool rebaseClientPath)
        {
            IDisposable ctx = new RewriteContext(CurrentVirtualPathAndQuery, false, this);

            int index = newVirtualPath.IndexOf('?');

            if (index >= 0)
            {
                string newQueryString = (index < (newVirtualPath.Length - 1)) ? newVirtualPath.Substring(index + 1) : string.Empty;
                _query         = new HttpValueCollection(newQueryString);
                newVirtualPath = newVirtualPath.Substring(0, index);
            }

            _currentVirtualFilePath = newVirtualPath;

            return(ctx);
        }
Пример #37
0
        internal static HttpValueCollection Create(IEnumerable <KeyValuePair <string, string> > pairs)
        {
            Contract.Assert(pairs != null);

            var hvc = new HttpValueCollection();

            // Ordering example:
            //   k=A&j=B&k=C --> k:[A,C];j=[B].
            foreach (KeyValuePair <string, string> kvp in pairs)
            {
                hvc.Add(kvp.Key, kvp.Value);
            }
#if !NETFX_CORE
            hvc.IsReadOnly = false;
#endif
            return(hvc);
        }
        /// <summary>
        /// This private method accesses oauth/token, but takes HTTP parameters as an input.
        ///
        /// This is a helper to implement the two different authentication methods.
        /// </summary>
        /// <param name="parameters">The URI parameters to sent to oauth/token</param>
        /// <returns>A task for the authentication response.</returns>
        private static async Task <AuthResponse> GetTokensAsync(HttpValueCollection parameters)
        {
            var uri = new UriBuilder("https://coinbase.com/oauth/token")
            {
                Query = parameters.ToString()
            }.Uri;

            using (var client = new HttpClient())
            {
                var httpResponse = await client.PostAsync(uri, new StringContent("")).ConfigureAwait(false);

                if (!httpResponse.IsSuccessStatusCode)
                {
                    throw new CoinbaseAuthenticationException(parameters, httpResponse.StatusCode);
                }

                return(JsonConvert.DeserializeObject <AuthResponse>(await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)));
            }
        }
Пример #39
0
        public async Task <OAuthToken> GetAccessToken(string callbackUrl)
        {
            //TODO hasn't handled error issue

            Uri uri = new Uri(callbackUrl);

            HttpValueCollection queryString = HttpUtility.ParseQueryString(uri.Query);

            string callbackCode = queryString["code"];

            Dictionary <string, string> contentDict = new Dictionary <string, string>()
            {
                { "code", callbackCode },
                { "grant_type", "authorization_code" }
            };

            string requestContent = JsonConvertHelper.SerializeObject(contentDict);

            OAuthToken oAuthToken = await RequestToken(contentDict);

            return(oAuthToken);
        }
Пример #40
0
        public void Register_ValidInput_Redirects()
        {
            var formData = new HttpValueCollection {
                {"UserName", "ChrisColumbus"},
                {"Email", "*****@*****.**"},
                {"Password", "explore_1492"},
                {"ConfirmPassword", "explore_1492"}
            };

            try
            {
                using (var scope = new MvcExecutorScope(new ExecutorSettings("Account/Register") { Form = formData }))
                {
                    Assert.IsTrue(scope.ViewData.ModelState.IsValid);
                    Assert.AreEqual(302, scope.HttpContext.Response.StatusCode);
                    Assert.AreEqual("/", scope.HttpContext.Response.RedirectLocation);
                }
            }
            finally
            {
                // Cleanup
                Membership.DeleteUser(formData["UserName"]);
            }
        }
Пример #41
0
 /// <summary>
 /// Creates the collection from XML node.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns></returns>
 public static HttpValueCollection CreateCollectionFromXmlNode(IXPathNavigable node)
 {
     HttpValueCollection result = new HttpValueCollection();
     if (node != null)
     {
         LoadCollectionFromXmlNode(result, node);
     }
     return result;
 }
 public static Uri GetNavigationUri(int todoListId)
 {
     HttpValueCollection values = new HttpValueCollection();
     values.Add(TodoListId, todoListId.ToString());
     return new Uri("/AddTodoItemPage.xaml?" + values.ToString(), UriKind.Relative);
 }
Пример #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpValueXPathNavigator"/> class.
 /// </summary>
 /// <param name="collection">The collection.</param>
 public HttpValueXPathNavigator(HttpValueCollection collection)
 {
     _Collection = collection;
 }
Пример #44
0
 /// <summary>
 /// Creates the collection from cookie header.
 /// </summary>
 /// <param name="cookieHeader">The cookie header.</param>
 /// <returns></returns>
 public static HttpValueCollection CreateCollectionFromCookieHeader(string cookieHeader)
 {
     if (string.IsNullOrEmpty(cookieHeader))
     {
         return new HttpValueCollection();
     }
     HttpValueCollection result = new HttpValueCollection();
     foreach (string entry in cookieHeader.Split(';'))
     {
         if (entry.Trim().Length == 0)
         {
             continue;
         }
         string[] nameValue = entry.Split('=');
         if (nameValue.Length == 1)
         {
             result[nameValue[0].Trim()] = string.Empty;
         }
         else
         {
             result[nameValue[0].Trim()] = string.Join("=", nameValue, 1, nameValue.Length - 1);
         }
     }
     return result;
 }
Пример #45
0
        internal void OverrideRequestState(ExecutorSettings settings)
        {
            if (settings.Url == null)
                throw new ArgumentException("The SimulatedRequestSettings must specifiy a Url.");

            _url = settings.Url;
            _cookies = (settings.Cookies != null) ? settings.Cookies : new HttpCookieCollection();
            _queryString = (settings.Url.Query.Length > 1) ? HttpValueCollection.Parse(settings.Url.Query.Substring(1)) : new HttpValueCollection();
            _form = (settings.Form  != null) ? settings.Form : new NameValueCollection();
            _headers = (settings.RequestHeaders != null) ? settings.RequestHeaders : new NameValueCollection();
            _httpMethod = !String.IsNullOrEmpty(settings.HttpMethod) ? settings.HttpMethod : (_form.Count > 0 ? "POST" : "GET");
            _isAuthenticated = settings.IsAuthenticated;
            _userAgent = settings.UserAgent;
            _contentType = !String.IsNullOrEmpty(settings.RequestContentType) ? settings.RequestContentType : "text/html";
            _referrer = settings.Referrer;

            //if (_settings.Files == null)
            //    _settings.Files = new ExecutorHttpFileCollection();
        }
Пример #46
0
 internal HttpValueCollection SwitchForm(HttpValueCollection form)
 {
     HttpValueCollection oldForm = _form;
     _form = form;
     return oldForm;
 }
Пример #47
0
 private NameValueCollection GetParams()
 {
     if (_params == null)
     {
         _params = new HttpValueCollection(64);
         FillInParamsCollection();
         _params.MakeReadOnly();
     }
     return _params;
 }
Пример #48
0
 // Used in integrated pipeline mode to invalidate the params collection 
 // after a change is made to the headers or server variables
 internal void InvalidateParams()
 {
     _params = null;
 }
Пример #49
0
        internal HttpRequest(VirtualPath virtualPath, String queryString)
        {
            _wr = null;
            _pathTranslated = virtualPath.MapPath();
            _httpMethod = "GET";
            _url = new Uri("http://localhost" + virtualPath.VirtualPathString);
            _path = virtualPath;
            _queryStringText = queryString;
            _queryStringOverriden = true;
            _queryString = new HttpValueCollection(_queryStringText, true, true, Encoding.Default);

            PerfCounters.IncrementCounter(AppPerfCounter.REQUESTS_EXECUTING);
        }
Пример #50
0
        /* 
         * Public constructor for request that come from arbitrary place
         * 
         * @param filename physical file name
         * @param queryString query string
         */

        /// <devdoc>
        ///    <para> 
        ///       Initializes an HttpRequest object. 
        ///    </para>
        /// </devdoc> 
        public HttpRequest(String filename, String url, String queryString)
        {
            _wr = null;
            _pathTranslated = filename;
            _httpMethod = "GET";
            _url = new Uri(url);
            _path = VirtualPath.CreateAbsolute(_url.AbsolutePath);
            _queryStringText = queryString;
            _queryStringOverriden = true;
            _queryString = new HttpValueCollection(_queryStringText, true, true, Encoding.Default);

            PerfCounters.IncrementCounter(AppPerfCounter.REQUESTS_EXECUTING);

        }
Пример #51
0
 /// <summary>
 /// Creates the collection from URL encoded.
 /// </summary>
 /// <param name="urlEncoded">The URL encoded.</param>
 /// <returns></returns>
 public static HttpValueCollection CreateCollectionFromUrlEncoded(string urlEncoded)
 {
     if (string.IsNullOrEmpty(urlEncoded))
     {
         return new HttpValueCollection();
     }
     HttpValueCollection result = new HttpValueCollection();
     foreach (string entry in urlEncoded.Split('&'))
     {
         if (entry.Trim().Length == 0)
         {
             continue;
         }
         string[] nameValue = entry.Split('=');
         if (nameValue.Length == 1)
         {
             result[HttpUtility.UrlDecode(nameValue[0])] = string.Empty;
         }
         else
         {
             result[HttpUtility.UrlDecode(nameValue[0])] = HttpUtility.UrlDecode(nameValue[1]);
         }
     }
     return result;
 }