public RestClient(string baseUri, HttpRequestHeadersConfiguration defaultHttpRequestHeadersConfiguration) { _client = new HttpClient { BaseAddress = new Uri(baseUri) }; _client.DefaultRequestHeaders.Accept.Clear(); _defaultHttpRequestHeadersConfiguration = defaultHttpRequestHeadersConfiguration; }
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); } }); }
public static HttpRequestHeadersConfiguration AcceptJson(this HttpRequestHeadersConfiguration configuration) { return(configuration += headers => headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"))); }
public static HttpRequestHeadersConfiguration Clear(this HttpRequestHeadersConfiguration configuration) { return(configuration += headers => headers.Clear()); }