Beispiel #1
0
        public void OnPostRequestHandlerExecute()
        {
            if (!Settings.IsHtmlRewritingEnabled)
            {
                return;
            }

            var httpContext = getCurrentHttpContext();

            if (httpContext.CurrentHandler is AssemblyResourceLoader)
            {
                // The AssemblyResourceLoader handler (for WebResource.axd requests) prevents further writes via some internal puke code.
                // This prevents response filters from working. The result is an empty response body!
                // So don't bother installing a filter for these requests. We don't need to rewrite them anyway.
                return;
            }

            if (!CanRewriteOutput(httpContext))
            {
                return;
            }

            var response = httpContext.Response;
            var tracker  = (IPlaceholderTracker)httpContext.Items[PlaceholderTrackerKey];
            var filter   = new PlaceholderReplacingResponseFilter(
                response,
                tracker
                );

            response.Filter = filter;
        }
        public void OnPostRequestHandlerExecute()
        {
            var httpContext = getCurrentHttpContext();

            if (!Settings.IsHtmlRewritingEnabled)
            {
                return;
            }
            if (!httpContext.IsHtmlRewritingEnabled())
            {
                return;
            }
            if (!CanRewriteOutput(httpContext))
            {
                return;
            }

            var response = httpContext.Response;
            var tracker  = (IPlaceholderTracker)httpContext.Items[PlaceholderTrackerKey];
            var filter   = new PlaceholderReplacingResponseFilter(
                response,
                tracker
                );

            response.Filter = filter;
        }
Beispiel #3
0
        public PlaceholderReplacingResponseFilter_Tests()
        {
            outputStream       = new MemoryStream();
            response           = new Mock <HttpResponseBase>();
            placeholderTracker = new Mock <IPlaceholderTracker>();

            placeholderTracker.Setup(h => h.ReplacePlaceholders(It.IsAny <string>()))
            .Returns <string>(s => s);

            response.SetupGet(r => r.Output.Encoding).Returns(Encoding.ASCII);
            response.SetupGet(r => r.Filter).Returns(outputStream);
            response.SetupGet(r => r.Headers).Returns(new NameValueCollection());
            filter = new PlaceholderReplacingResponseFilter(response.Object, placeholderTracker.Object);
        }
        public PlaceholderReplacingResponseFilter_Tests()
        {
            outputStream = new MemoryStream();
            response = new Mock<HttpResponseBase>();
            placeholderTracker = new Mock<IPlaceholderTracker>();

            placeholderTracker.Setup(h => h.ReplacePlaceholders(It.IsAny<string>()))
                      .Returns<string>(s => s);

            response.SetupGet(r => r.Output.Encoding).Returns(Encoding.ASCII);
            response.SetupGet(r => r.Filter).Returns(outputStream);
            response.SetupGet(r => r.Headers).Returns(new NameValueCollection());
            filter = new PlaceholderReplacingResponseFilter(response.Object, placeholderTracker.Object);
        }
        public void OnPostRequestHandlerExecute()
        {
            var httpContext = getCurrentHttpContext();
            if (!Settings.IsHtmlRewritingEnabled) return;
            if (!httpContext.IsHtmlRewritingEnabled()) return;
            if (!CanRewriteOutput(httpContext)) return;

            var response = httpContext.Response;
            var tracker = (IPlaceholderTracker)httpContext.Items[PlaceholderTrackerKey];
            var filter = new PlaceholderReplacingResponseFilter(
                response,
                tracker
            );
            response.Filter = filter;
        }
        public void OnPostRequestHandlerExecute()
        {
            if (!Settings.IsHtmlRewritingEnabled) return;

            var httpContext = getCurrentHttpContext();
            if (httpContext.CurrentHandler is AssemblyResourceLoader)
            {
                // The AssemblyResourceLoader handler (for WebResource.axd requests) prevents further writes via some internal puke code.
                // This prevents response filters from working. The result is an empty response body!
                // So don't bother installing a filter for these requests. We don't need to rewrite them anyway.
                return;
            }

            if (!CanRewriteOutput(httpContext)) return;

            var response = httpContext.Response;
            var tracker = (IPlaceholderTracker)httpContext.Items[PlaceholderTrackerKey];
            var filter = new PlaceholderReplacingResponseFilter(
                response,
                tracker
            );
            response.Filter = filter;
        }