Пример #1
0
        /// <summary>
        /// Posts the XML.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="xmlFragment">The XML fragment.</param>
        /// <param name="proxyLocation">The proxy location.</param>
        /// <param name="bypassProxy">if set to <c>true</c> [bypass proxy].</param>
        /// <returns></returns>
        public static string PostXml(this HttpWebRequest request, string xmlFragment, Uri proxyLocation, bool bypassProxy)
        {
            if (request == null)
            {
                return(null);
            }

            request
            .WithProxy(proxyLocation, bypassProxy)
            .WithRequestBody(xmlFragment, "POST")
            .ContentType = "text/xml";

            var response = request.DownloadToString();

            return(response);
        }
Пример #2
0
        /// <summary>
        /// Posts the form.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="resourceIndicator">The resource indicator.</param>
        /// <param name="postData">The post data.</param>
        /// <param name="proxyLocation">The proxy location.</param>
        /// <param name="bypassProxy">if set to <c>true</c> [bypass proxy].</param>
        public static string PostForm(this HttpWebRequest request, Uri resourceIndicator, Hashtable postData, Uri proxyLocation, bool bypassProxy)
        {
            if (request == null)
            {
                return(null);
            }

            var postParams = GetPostData(postData);

            request
            .WithProxy(proxyLocation, bypassProxy)
            .WithRequestBody(postParams, "POST")
            .ContentType = "application/x-www-form-urlencoded";

            var response = request.DownloadToString();

            return(response);
        }
Пример #3
0
 /// <summary>
 /// Downloads to string.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns></returns>
 public static string DownloadToString(this HttpWebRequest request)
 {
     return(request.DownloadToString(null, bypassProxy: true));
 }