BetterHttpClient.HttpClient.DownloadBytes C# (CSharp) Метод

DownloadBytes() публичный Метод

Execute GET request.
public DownloadBytes ( string url ) : byte[]
url string
Результат byte[]
        public byte[] DownloadBytes(string url)
        {
            return DownloadBytes(url, null);
        }
        /// <summary>

Same methods

HttpClient::DownloadBytes ( string url, NameValueCollection data ) : byte[]

Usage Example

Пример #1
0
        private byte[] DownloadBytes(string url, NameValueCollection data, Proxy proxy, string requiredString = null, CookieContainer cookies = null, string referer = null)
        {
            if (requiredString == null)
            {
                requiredString = RequiredString;
            }

            HttpClient client = CreateHttpClient();

            client.Proxy = proxy;
            if (cookies != null)
            {
                client.Cookies = cookies;
            }
            if (referer != null)
            {
                client.Referer = referer;
            }

            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);
        }