public static HttpWebResponse GetRangedResponse(HttpDownloadInfo info, long start, long end, WebRequest request, EventHandler <AfterGettingResponseEventArgs> after) { var response = (HttpWebResponse)request.GetResponse(); after.Raise(null, new AfterGettingResponseEventArgs(response)); if (response.ContentLength != end - start + 1) { throw new ReturnedContentSizeWrongException(start, end, response.ContentLength, end - start + 1); } return(response); }
public static HttpWebRequest CreateHttpRequest(HttpDownloadInfo info, long start, long end, EventHandler <BeforeSendingRequestEventArgs> before) { if (start < 0 || (info.ContentSize > 0 && start >= info.ContentSize)) { throw new Exception("Range start index is out of the bounds"); } if (start > 0 && !info.AcceptRanges) { throw new Exception("Remote file doesn't support ranges"); } var request = CreateHttpRequest(info.Url, before, false); if (info.ContentSize > 0) { request.AddRange(start, end); } return(request); }
public RemoteFilePropertiesChangedException(HttpDownloadInfo originalInfo, HttpDownloadInfo currentInfo) { this.OriginalInfo = originalInfo; this.CurrentInfo = currentInfo; }