private byte[] DownloadBytes(string url, NameValueCollection data, Proxy proxy, CookieContainer cookies = null, NameValueCollection customHeaders = null)
{
HttpClient client = CreateHttpClient(customHeaders);
client.Proxy = proxy;
if (cookies != null) client.Cookies = cookies;
try
{
return client.DownloadBytes(url, data);
}
catch (WebException e)
{
if (e.Response != null && (e.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotFound)
throw new WebPageNotFoundException();
proxy.IsOnline = false;
}
return null;
}
private HttpClient CreateHttpClient(NameValueCollection customHeaders = null)