Esempio n. 1
0
        public HttpRequest query(string parameter, string value = null)
        {
            var url = new UriBuilder(this.URL);

            var newQueryString = new FormUrlEncodedContent(new Dictionary <string, string>
            {
                { parameter, value }
            }).ReadAsStringAsync().Result;

            if (value == null)
            {
                newQueryString = newQueryString.Substring(0, newQueryString.Length - 1);
            }

            if (url.Query == "")
            {
                url.Query = newQueryString;
            }
            else
            {
                url.Query = string.Join("&", url.Query.Substring(1), newQueryString);
            }

            URL = url.Uri;

            return(this);
        }