예제 #1
0
 public RestClient(string baseUri, HttpRequestHeadersConfiguration defaultHttpRequestHeadersConfiguration)
 {
     _client = new HttpClient
     {
         BaseAddress = new Uri(baseUri)
     };
     _client.DefaultRequestHeaders.Accept.Clear();
     _defaultHttpRequestHeadersConfiguration = defaultHttpRequestHeadersConfiguration;
 }
예제 #2
0
 public static HttpRequestHeadersConfiguration AddRange(this HttpRequestHeadersConfiguration configuration, IDictionary <string, IEnumerable <string> > defaultHeaders)
 {
     return(configuration += headers =>
     {
         foreach (var header in defaultHeaders)
         {
             headers.Add(header.Key, header.Value);
         }
     });
 }
예제 #3
0
 public static HttpRequestHeadersConfiguration AcceptJson(this HttpRequestHeadersConfiguration configuration)
 {
     return(configuration += headers => headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")));
 }
예제 #4
0
 public static HttpRequestHeadersConfiguration Clear(this HttpRequestHeadersConfiguration configuration)
 {
     return(configuration += headers => headers.Clear());
 }