X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=na-get-lib%2FNaGet.Net%2FDownloader.cs;h=623e78709a31e82e8ac4e297e187a54e8965d941;hb=b9811de7a080dbce7eed4a92e68de73ba831c8d0;hp=d389381e3596e30aec473bb8bfcf53163be67c82;hpb=98e241e0f7d1b3e5a4048c957f135254a6d1f24f;p=applistation%2FAppliStation.git
diff --git a/na-get-lib/NaGet.Net/Downloader.cs b/na-get-lib/NaGet.Net/Downloader.cs
index d389381..623e787 100644
--- a/na-get-lib/NaGet.Net/Downloader.cs
+++ b/na-get-lib/NaGet.Net/Downloader.cs
@@ -73,7 +73,7 @@ public class Downloader : NaGetTask
///
/// ã¢ã¯ã»ã¹URL
///
- protected string url;
+ protected Uri url;
///
/// ä¿åå
@@ -129,7 +129,7 @@ public class Downloader : NaGetTask
/// ä¿åå
ãã¡ã¤ã«ãã¹
public void Download(string url, string filepath)
{
- this.url = url;
+ this.url = new Uri(url);
this.filepath = filepath;
try {
@@ -165,6 +165,11 @@ public class Downloader : NaGetTask
request.Proxy = this.Proxy;
request.CachePolicy = new System.Net.Cache.RequestCachePolicy(CacheLevel);
+ HttpWebRequest httpRequest = request as HttpWebRequest;
+ if (httpRequest != null) {
+ httpRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
+ }
+
if (cancelCalled) {
throw new NaGetTaskCanceledException(string.Empty);
}
@@ -249,10 +254,13 @@ public class Downloader : NaGetTask
// æ´æ°æ¥ãè£å®
if (File.Exists(filepath)) {
- if (response is HttpWebResponse) {
- File.SetLastWriteTime(filepath, ((HttpWebResponse) response).LastModified);
- } else if (response is FtpWebResponse) {
- File.SetLastWriteTime(filepath, ((FtpWebResponse) response).LastModified);
+ HttpWebResponse httpResponse = response as HttpWebResponse;
+ FtpWebResponse ftpResponse = response as FtpWebResponse;
+
+ if (httpResponse != null) {
+ File.SetLastWriteTime(filepath, httpResponse.LastModified);
+ } else if (ftpResponse != null) {
+ File.SetLastWriteTime(filepath, ftpResponse.LastModified);
}
}
} finally {
@@ -334,10 +342,11 @@ public class Downloader : NaGetTask
/// Content-Dispositionãããããåå¾ãããã¯URLã®æ«å°¾ããæ¨å®ãã¾ã
/// ã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ã
/// åå¾ãããã¡ã¤ã«å
- private string getFileNameFromWebResponse(WebResponse response)
+ private static string getFileNameFromWebResponse(WebResponse response)
{
- if (response is HttpWebResponse) {
- string contentDisposition = ((HttpWebResponse) response).Headers["Content-Disposition"];
+ HttpWebResponse httpresp = response as HttpWebResponse;
+ if (httpresp != null) {
+ string contentDisposition = httpresp.Headers["Content-Disposition"];
if (! string.IsNullOrEmpty(contentDisposition)) {
try {
@@ -350,7 +359,7 @@ public class Downloader : NaGetTask
}
}
- return NaGet.Utils.Url2filename(response.ResponseUri.ToString());
+ return NaGet.Utils.Url2filename(response.ResponseUri);
}
}