Esempio n. 1
0
        public static Task <DownloadFileRequest> DownloadFile(string url, bool noCache)
        {
            if (HttpClientProvider.HasCustomCreation || !WebRequestHelper.HasCustomRequestHandler)
            {
                return(HttpClientDownloadFileRequest.Create(url, noCache));
            }

            return(WebRequestDownloadFileRequest.Create(url, noCache));
        }
Esempio n. 2
0
        public static Task <DownloadFileRequest> Create(string url, bool noCache)
        {
            var response = WebRequestHelper.GetResponse(
                () => (HttpWebRequest)WebRequest.Create(url),
                r => {
                if (noCache)
                {
                    r.Headers ["Pragma"] = "no-cache";
                }
            }
                );

            var request = new WebRequestDownloadFileRequest {
                response = response,
                stream   = response.GetResponseStream()
            };

            return(Task.FromResult <DownloadFileRequest> (request));
        }