示例#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();
            }
        }
示例#2
0
        public FileRepository(IHttpWebClient httpWebClient)
        {
            if (httpWebClient == null)
            {
                throw new ArgumentNullException(nameof(httpWebClient));
            }

            _httpWebClient = httpWebClient;
        }
示例#3
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));
            }
        }
示例#4
0
 public CossClient(ICossSignator signator, IDateTimeUtil dateTimeUtil, IHttpWebClient httpWebClient)
 {
     _signator      = signator;
     _dateTimeUtil  = dateTimeUtil;
     _httpWebClient = httpWebClient;
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GitHubCommitService"/> class.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="webclient">The webclient.</param>
 /// <param name="jsonConverter">The json converter.</param>
 public GitHubCommitService(IConfig config, IHttpWebClient webclient, IJsonConverter jsonConverter)
 {
     _config        = config;
     _webClient     = webclient;
     _jsonConverter = jsonConverter;
 }