public CustomHttpResult GetString(HttpTransportSettings settings) { using (var client = BuildHttpClient(settings)) { var res = client.GetAsync(settings.Url).Result; var retVal = new CustomHttpResult { IsSuccessStatusCode = res.IsSuccessStatusCode, HttpStatusCode = res.StatusCode, Content = res.Content.ReadAsStringAsync().Result }; return(retVal); } }
public CustomHttpResult ProcessRequest(HttpRequestMessage requestMessage) { using (var client = BuildHttpClient()) { var res = client.SendAsync(requestMessage).Result; res.EnsureSuccessStatusCode(); var retVal = new CustomHttpResult { IsSuccessStatusCode = res.IsSuccessStatusCode, HttpStatusCode = res.StatusCode, Content = res.Content.ReadAsStringAsync().Result }; return(retVal); } }
public CustomHttpResult PostEncodedParam(HttpTransportSettings settings, FormUrlEncodedContent content) { using (var client = BuildHttpClient(settings)) { var res = client.PostAsync(settings.Url, content).Result; var retVal = new CustomHttpResult { IsSuccessStatusCode = res.IsSuccessStatusCode, HttpStatusCode = res.StatusCode, Content = res.Content.ReadAsStringAsync().Result }; return(retVal); } }
public CustomHttpResult PostRawBytes(HttpTransportSettings settings, byte[] bytes) { using (var client = BuildHttpClient(settings)) { var request = new HttpRequestMessage { RequestUri = settings.Url, Method = HttpMethod.Post, Content = new ByteArrayContent(bytes), }; request.Content.Headers.ContentType = new MediaTypeHeaderValue(settings.ContentType); var res = client.PostAsync(settings.Url, new ByteArrayContent(bytes)).Result; var retVal = new CustomHttpResult { IsSuccessStatusCode = res.IsSuccessStatusCode, HttpStatusCode = res.StatusCode, Content = res.Content.ReadAsStringAsync().Result }; return(retVal); } }