Ejemplo n.º 1
0
        /// <summary>
        /// Submits request to endpoint and get entityResponse back - ASYNC.
        /// </summary>
        /// <returns></returns>
        public async Task <IHttpWebResponse> GetResponseAsync()
        {
            this.PreProcessSetup();
            IHttpWebClient      httpClient      = HttpWebClient.HttpClient;
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await httpClient.SendAsync(this.httpRequestMessage);

                string content = string.Empty;
                if (responseMessage.Content != null)
                {
                    content = await responseMessage.Content.ReadAsStringAsync();
                }

                return(this.ProcessResponse(
                           responseMessage,
                           content));
            }
            finally
            {
                responseMessage?.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Submits request to endpoint and get entityResponse back.
        /// </summary>
        /// <returns></returns>
        public IHttpWebResponse GetResponse()
        {
            this.PreProcessSetup();
            IHttpWebClient httpClient = HttpWebClient.HttpClient;

            using (HttpResponseMessage response = httpClient.SendAsync(this.httpRequestMessage).GetAwaiter().GetResult())
            {
                string content = string.Empty;
                if (response.Content != null)
                {
                    content = response.Content.ReadAsStringAsync().Result;
                }

                return(this.ProcessResponse(
                           response,
                           content));
            }
        }