/// <exception cref="ObjectDisposedException"></exception>
        public async Task <DownloadResult <string> > DownloadAsStringAsync(Uri requestUri, string acceptMediaType = "*/*")
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            var response = await DownloadAsync(requestUri, _requestDelay, acceptMediaType);

            if (response == null || !response.IsSuccessStatusCode)
            {
                var request = _proxy.GenerateRequestMessage(HttpMethod.Get, requestUri, acceptMediaType);
                return(new DownloadResult <string>(request, response));
            }

            var responseString = await _proxy.GetResponseContentStringAsync(response);

            var downloadResult = new DownloadResult <string>(responseString);

            return(downloadResult);
        }
        /// <exception cref="ObjectDisposedException"></exception>
        public async Task <DownloadResult <byte[]> > DownloadFileAsync(Uri requestUri)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            var response = await DownloadAsync(requestUri, _fileRequestDelay, acceptMediaType : "*/*");

            if (response == null || !response.IsSuccessStatusCode)
            {
                var request = _proxy.GenerateRequestMessage(HttpMethod.Get, requestUri, acceptMediaType: "*/*");
                return(new DownloadResult <byte[]>(request, response));
            }

            var memoryStream = new MemoryStream();
            await response.Content.CopyToAsync(memoryStream);

            var downloadResult = new DownloadResult <byte[]>(memoryStream.ToArray());

            return(downloadResult);
        }
 public DownloadException(string message, DownloadResult <T> downloadResult, Exception inner)
     : base(message, inner)
 {
     DownloadResult = downloadResult;
 }
 public DownloadException(string message, DownloadResult <T> downloadResult)
     : base(message)
 {
     DownloadResult = downloadResult;
 }