/// </summary>\r
public event EventHandler<DownloadEventArgs> DownloadEventRaised;\r
\r
+ /// <summary>\r
+ /// アクセスURL\r
+ /// </summary>\r
protected string url;\r
\r
+ /// <summary>\r
+ /// 保存先\r
+ /// </summary>\r
protected string filepath;\r
\r
+ /// <summary>\r
+ /// リクエストオブジェクト\r
+ /// </summary>\r
protected WebRequest request;\r
\r
+ /// <summary>\r
+ /// レスポンスオブジェクト。応答がくるまではnullである。\r
+ /// </summary>\r
protected WebResponse response;\r
\r
+ /// <summary>\r
+ /// ダウンロード要求時のキャッシュレベル。デフォルトではキャッシュ無視\r
+ /// </summary>\r
+ public System.Net.Cache.RequestCacheLevel CacheLevel = System.Net.Cache.RequestCacheLevel.NoCacheNoStore;\r
+ \r
private bool cancelCalled = false;\r
\r
private bool done = false;\r
\r
try {\r
request = WebRequest.Create(url);\r
- request.Proxy = (Proxy == null)? DefaultProxy : Proxy; \r
- if (request is HttpWebRequest) {\r
- request.CachePolicy = new System.Net.Cache.HttpRequestCachePolicy(\r
- System.Net.Cache.HttpRequestCacheLevel.NoCacheNoStore);\r
- }\r
+ request.Proxy = (Proxy == null)? DefaultProxy : Proxy;\r
+ request.CachePolicy = new System.Net.Cache.RequestCachePolicy(CacheLevel);\r
\r
if (cancelCalled) {\r
throw new NaGetTaskCanceledException(string.Empty);\r
case DownloadEventType.STARTED:\r
case DownloadEventType.DOWNLOADING:\r
case DownloadEventType.COMPLETED:\r
- try {\r
+ if (e.TaskProgressPercent >= 0) {\r
e.TaskMessage = string.Format("{0} bytes ({1} %)", e.DownloadSize, (int) e.TaskProgressPercent);\r
- } catch (DivideByZeroException) {\r
+ } else {\r
e.TaskMessage = string.Format("{0} bytes", e.DownloadSize);\r
}\r
\r
\r
if (stopwatch != null && stopwatch.IsRunning && stopwatch.ElapsedMilliseconds > 3000) {\r
long bpers = e.DownloadSize * 1000 / stopwatch.ElapsedMilliseconds;\r
- try {\r
+ if ((e.TaskProgressPercent >= 0) && (bpers > 0)) {\r
TimeSpan rest = TimeSpan.FromSeconds((max - e.DownloadSize) / bpers);\r
e.TaskMessage += string.Format(" 推定残り時間:{0} ({1}/s)", rest, NaGet.Utils.FormatSize(bpers));\r
- } catch {\r
+ } else {\r
e.TaskMessage += string.Format(" ({0}/s)", NaGet.Utils.FormatSize(bpers));\r
}\r
}\r