/// <summary>\r
/// アクセスURL\r
/// </summary>\r
- protected string url;\r
+ protected Uri url;\r
\r
/// <summary>\r
/// 保存先\r
/// <param name="filepath">保存先ファイルパス</param>\r
public void Download(string url, string filepath)\r
{\r
- this.url = url;\r
+ this.url = new Uri(url);\r
this.filepath = filepath;\r
\r
try {\r
request.Proxy = this.Proxy;\r
request.CachePolicy = new System.Net.Cache.RequestCachePolicy(CacheLevel);\r
\r
+ HttpWebRequest httpRequest = request as HttpWebRequest;\r
+ if (httpRequest != null) {\r
+ httpRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; \r
+ }\r
+ \r
if (cancelCalled) {\r
throw new NaGetTaskCanceledException(string.Empty);\r
}\r
\r
// 更新日を補完\r
if (File.Exists(filepath)) {\r
- if (response is HttpWebResponse) {\r
- File.SetLastWriteTime(filepath, ((HttpWebResponse) response).LastModified);\r
- } else if (response is FtpWebResponse) {\r
- File.SetLastWriteTime(filepath, ((FtpWebResponse) response).LastModified);\r
+ HttpWebResponse httpResponse = response as HttpWebResponse;\r
+ FtpWebResponse ftpResponse = response as FtpWebResponse;\r
+ \r
+ if (httpResponse != null) {\r
+ File.SetLastWriteTime(filepath, httpResponse.LastModified);\r
+ } else if (ftpResponse != null) {\r
+ File.SetLastWriteTime(filepath, ftpResponse.LastModified);\r
}\r
}\r
} finally {\r
/// <remarks>Content-Dispositionヘッダから取得あるいはURLの末尾から推定します</remarks>\r
/// <param name="response">レスポンスオブジェクト</param>\r
/// <returns>取得したファイル名</returns>\r
- private string getFileNameFromWebResponse(WebResponse response)\r
+ private static string getFileNameFromWebResponse(WebResponse response)\r
{\r
- if (response is HttpWebResponse) {\r
- string contentDisposition = ((HttpWebResponse) response).Headers["Content-Disposition"];\r
+ HttpWebResponse httpresp = response as HttpWebResponse;\r
+ if (httpresp != null) {\r
+ string contentDisposition = httpresp.Headers["Content-Disposition"];\r
\r
if (! string.IsNullOrEmpty(contentDisposition)) {\r
try {\r
}\r
}\r
\r
- return NaGet.Utils.Url2filename(response.ResponseUri.ToString());\r
+ return NaGet.Utils.Url2filename(response.ResponseUri);\r
}\r
}\r
\r