Ejemplo n.º 1
0
 private static bool IsIIS7WorkerRequest(HttpWorkerRequest workerRequest)
 {
     return workerRequest.GetType().FullName == IIS7WorkerRequestTypeName;
 }
        /// <summary>
        /// Perists the status.
        /// </summary>
        /// <param name="key">The status key.</param>
        /// <param name="length">The total request length.</param>
        /// <param name="app">The application.</param>
        /// <param name="worker">The HTTP worker request.</param>
        void PersistStatus(string key, long length, HttpApplication app, HttpWorkerRequest worker)
        {
            UploadManager.Instance.SetStatus(_status, key);

            if (length / 1024 > GetMaxRequestLength(app.Context))
            {
                // End the request if the maximum request length is exceeded.
                EndRequestOnRequestLengthExceeded(app.Context.Response, worker, app.Context, worker.GetType().FullName == "System.Web.Hosting.IIS7WorkerRequest");
                return;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 传入已上传完的数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="textParts"></param>
        void InjectTextParts(HttpWorkerRequest request, byte[] textParts)
        {
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic;

            Type type = request.GetType();

            while ((type != null) && (type.FullName != "System.Web.Hosting.ISAPIWorkerRequest"))
            {
                type = type.BaseType;
            }

            if (type != null)
            {
                type.GetField("_contentAvailLength", bindingFlags).SetValue(request, textParts.Length);
                type.GetField("_contentTotalLength", bindingFlags).SetValue(request, textParts.Length);
                type.GetField("_preloadedContent", bindingFlags).SetValue(request, textParts);
                type.GetField("_preloadedContentRead", bindingFlags).SetValue(request, true);
            }
        }
Ejemplo n.º 4
0
        void InjectTextParts(HttpWorkerRequest worker, byte[] textParts)
        {
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic;

            Type type = worker.GetType();

            while ((type != null) && !(type.FullName == "System.Web.Hosting.ISAPIWorkerRequest" ||
                type.FullName == "Microsoft.VisualStudio.WebHost.Request" ||
                type.FullName == "Cassini.Request"))
            {
                type = type.BaseType;
            }

            if (type != null)
            {
                switch (type.FullName)
                {
                    case "System.Web.Hosting.ISAPIWorkerRequest":
                        type.GetField("_contentAvailLength", bindingFlags).SetValue(worker, textParts.Length);
                        type.GetField("_contentTotalLength", bindingFlags).SetValue(worker, textParts.Length);
                        type.GetField("_preloadedContent", bindingFlags).SetValue(worker, textParts);
                        type.GetField("_preloadedContentRead", bindingFlags).SetValue(worker, true);

                        break;
                    case "Cassini.Request":
                    case "Microsoft.VisualStudio.WebHost.Request":
                        type.GetField("_contentLength", bindingFlags).SetValue(worker, textParts.Length);
                        type.GetField("_preloadedContent", bindingFlags).SetValue(worker, textParts);
                        type.GetField("_preloadedContentLength", bindingFlags).SetValue(worker, textParts.Length);

                        break;
                }
            }
        }