Пример #1
0
        /// <summary>
        ///     Constructor for HttpCall
        /// </summary>
        /// <param name="method"></param>
        /// <param name="headers"></param>
        /// <param name="url"></param>
        /// <param name="requestBody"></param>
        /// <param name="contentType"></param>
        public HttpCall(HttpMethod method, HttpCallHeaders headers, string url, string requestBody,
                        ContentTypeValues contentType)
        {
            var handler = new HttpClientHandler()
            {
                AllowAutoRedirect      = false,
                AutomaticDecompression = DecompressionMethods.None,
            };

            _httpClient = new HttpClient(handler);

            _method      = method;
            _headers     = headers;
            _url         = url;
            _requestBody = requestBody;
            _contentType = contentType;
        }
Пример #2
0
        /// <summary>
        ///     Constructor for HttpCall
        /// </summary>
        /// <param name="method"></param>
        /// <param name="headers"></param>
        /// <param name="url"></param>
        /// <param name="requestBody"></param>
        /// <param name="contentType"></param>
        public HttpCall(HttpMethod method, HttpCallHeaders headers, string url, string requestBody, ContentTypeValues contentType)
        {
            var httpBaseFilter = new HttpBaseProtocolFilter
            {
                AllowUI                = false,
                AllowAutoRedirect      = true,
                AutomaticDecompression = true
            };

            httpBaseFilter.CacheControl.ReadBehavior  = HttpCacheReadBehavior.MostRecent;
            httpBaseFilter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;
            _webClient   = new HttpClient(httpBaseFilter);
            _method      = method;
            _headers     = headers;
            _url         = url;
            _requestBody = requestBody;
            _contentType = contentType;
        }
Пример #3
0
 /// <summary>
 ///     Factory method to build a HttpCall object for a POST request with a specific content type
 /// </summary>
 /// <param name="headers"></param>
 /// <param name="url"></param>
 /// <param name="requestBody"></param>
 /// <param name="contentType"></param>
 /// <returns></returns>
 public static HttpCall CreatePost(HttpCallHeaders headers, string url, string requestBody,
                                   ContentTypeValues contentType)
 {
     return(new HttpCall(HttpMethod.Post, headers, url, requestBody, contentType));
 }
Пример #4
0
 /// <summary>
 ///     Factory method to build a HttpCall object for a GET request with additional HTTP request headers
 /// </summary>
 /// <param name="headers"></param>
 /// <param name="url"></param>
 /// <returns></returns>
 public static HttpCall CreateGet(HttpCallHeaders headers, string url)
 {
     return(new HttpCall(HttpMethod.Get, headers, url, null, ContentTypeValues.None));
 }