private void BoundaryInfoWaiterMeetGuard(object sender, EventArgs e) { var sw = sender as EntityBodyChunkStateWaiter; var cdi = UploadProgressUtils.GetContentDisposition(sw.Value); sw.Reset(); if (!cdi.IsFile) { _lastCdName = cdi.name; _current = _formValueWaiter; _current.Wait(sw); } else { _statistic.BeginFileUpload(cdi.filename); _current = _boundaryWaiter; _current.Wait(sw); } }
internal EntityBodyInspector(HttpUploadWorkerRequest request) { _statistic = new UploadProgressStatistic { TotalBytes = request.GetTotalEntityBodyLength() }; var contentType = request.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentType); var boundary = string.Format("--{0}\r\n", UploadProgressUtils.GetBoundary(contentType)); _boundaryWaiter = new EntityBodyChunkStateWaiter(boundary, false); _boundaryWaiter.MeetGuard += BoundaryWaiterMeetGuard; _current = _boundaryWaiter; _boundaryInfoWaiter = new EntityBodyChunkStateWaiter("\r\n\r\n", true); _boundaryInfoWaiter.MeetGuard += BoundaryInfoWaiterMeetGuard; _formValueWaiter = new EntityBodyChunkStateWaiter("\r\n", true); _formValueWaiter.MeetGuard += FormValueWaiterMeetGuard; _lastCdName = string.Empty; }
private void OnBeginRequest(object sender, EventArgs e) { var request = ((HttpApplication)sender).Context.Request; var origWr = (HttpWorkerRequest)RequestWorkerField.GetValue(request); if (UploadProgressUtils.IsUpload(origWr)) { var s = request.RawUrl; if (string.IsNullOrEmpty(s)) { return; } if (!IsUrlWithExtension.IsMatch(s)) { return; } var newWr = new HttpUploadWorkerRequest(origWr); RequestWorkerField.SetValue(request, newWr); } }