Пример #1
0
		public LazyWebROCollection (RequestValidationSource validationSource, WebROCollection wrapped)
		{
			if (wrapped == null)
				throw new ArgumentNullException ("wrapped");
			
			this.validationSource = validationSource;
			this.wrapped = wrapped;
		}
        internal void Execute(IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude)
        {
#if !TARGET_J2EE
            // If the target handler is not Page, the transfer must not occur.
            // InTransit == true means we're being called from Transfer
            bool is_static = (handler is StaticFileHandler);
            if (isTransfer && !(handler is Page) && !is_static)
            {
                throw new HttpException("Transfer is only allowed to .aspx and static files");
            }
#endif

            HttpRequest request  = context.Request;
            string      oldQuery = request.QueryStringRaw;
            if (queryString != null)
            {
                request.QueryStringRaw = queryString;
            }
            else if (!preserveForm)
            {
                request.QueryStringRaw = String.Empty;
            }

            HttpResponse    response = context.Response;
            WebROCollection oldForm  = request.Form as WebROCollection;
            if (!preserveForm)
            {
                request.SetForm(new WebROCollection());
            }

            TextWriter output = writer;
            if (output == null)
            {
                output = response.Output;
            }

            TextWriter previous     = response.SetTextWriter(output);
            string     oldExePath   = request.CurrentExecutionFilePath;
            bool       oldIsInclude = context.IsProcessingInclude;
            try
            {
                context.PushHandler(handler);
                if (is_static) // Not sure if this should apply to Page too
                {
                    request.SetFilePath(exePath);
                }

                request.SetCurrentExePath(exePath);
                context.IsProcessingInclude = isInclude;

                if (!(handler is IHttpAsyncHandler))
                {
                    handler.ProcessRequest(context);
                }
                else
                {
                    IHttpAsyncHandler asyncHandler    = (IHttpAsyncHandler)handler;
                    IAsyncResult      ar              = asyncHandler.BeginProcessRequest(context, null, null);
                    WaitHandle        asyncWaitHandle = ar != null ? ar.AsyncWaitHandle : null;
                    if (asyncWaitHandle != null)
                    {
                        asyncWaitHandle.WaitOne();
                    }
                    asyncHandler.EndProcessRequest(ar);
                }
            }
            finally
            {
                if (oldQuery != request.QueryStringRaw)
                {
                    if (oldQuery != null && oldQuery.Length > 0)
                    {
                        oldQuery = oldQuery.Substring(1);  // Ignore initial '?'
                        request.QueryStringRaw = oldQuery; // which is added here.
                    }
                    else
                    {
                        request.QueryStringRaw = String.Empty;
                    }
                }

                response.SetTextWriter(previous);
                if (!preserveForm)
                {
                    request.SetForm(oldForm);
                }

                context.PopHandler();
                request.SetCurrentExePath(oldExePath);
                context.IsProcessingInclude = oldIsInclude;
            }
        }
Пример #3
0
		internal string ApplyUrlMapping (string url)
		{
			if (urlMappings == null)
				return url;

			string relUrl = VirtualPathUtility.ToAppRelative (url);
			UrlMapping um = null;
			
			foreach (UrlMapping u in urlMappings) {
				if (u == null)
					continue;
				if (String.Compare (relUrl, u.Url, StringComparison.Ordinal) == 0) {
					um = u;
					break;
				}
			}

			if (um == null)
				return url;

			string rawUrl = VirtualPathUtility.ToAbsolute (um.MappedUrl.Trim ());
			Uri newUrl = new Uri ("http://host.com" + rawUrl);

			if (url_components != null) {
				url_components.Path = newUrl.AbsolutePath;
				url_components.Query = newUrl.Query.TrimStart (queryTrimChars);
				query_string_nvc = new WebROCollection ();
				HttpUtility.ParseQueryString (newUrl.Query, Encoding.Default, query_string_nvc);
				query_string_nvc.Protect ();
			} else
				BuildUrlComponents (newUrl.AbsolutePath, newUrl.Query);

			return url_components.Path;
		}
Пример #4
0
		public HttpRequest (string filename, string url, string queryString)
		{
			// warning 169: what are we supposed to do with filename?
			
			//this.filename = filename;

			orig_url = url;
			url_components = new UriBuilder (url);
			url_components.Query = queryString;
			
			query_string_nvc = new WebROCollection ();
			if (queryString != null)
				HttpUtility.ParseQueryString (queryString, Encoding.Default, query_string_nvc);
			query_string_nvc.Protect ();
		}
Пример #5
0
		// Internal, dont know what it does, so flagged as public so we can see it.
		internal void SetForm (WebROCollection coll)
		{
			form = coll;
		}
Пример #6
0
		internal void SetQueryStringCollection (WebROCollection coll, bool lazyValidation)
		{
			if (coll == null)
				return;
			query_string_nvc = coll;
			lazyQueryStringValidation = lazyValidation;
		}
Пример #7
0
		internal void SetFormCollection (WebROCollection coll, bool lazyValidation)
		{
			if (coll == null)
				return;
			form = coll;
			lazyFormValidation = lazyValidation;
		}