protected WebClient CreateWebClient()
{
var client = new WebClient();
client.Headers.Add("X-ApiKey", _apiKey);
client.Headers.Add("content-type", "application/json; charset=utf-8");
client.Encoding = System.Text.Encoding.UTF8;
if (WebProxy != null)
{
client.Proxy = WebProxy;
}
else if (WebRequest.DefaultWebProxy != null)
{
Uri proxyUri = WebRequest.DefaultWebProxy.GetProxy(new Uri(RaygunSettings.Settings.ApiEndpoint.ToString()));
if (proxyUri != null && proxyUri.AbsoluteUri != RaygunSettings.Settings.ApiEndpoint.ToString())
{
client.Proxy = new WebProxy(proxyUri, false);
if (ProxyCredentials == null)
{
client.UseDefaultCredentials = true;
client.Proxy.Credentials = CredentialCache.DefaultCredentials;
}
else
{
client.UseDefaultCredentials = false;
client.Proxy.Credentials = ProxyCredentials;
}
}
}
return client;
}