Permalink
Browse files

closed #178 Support application/xhtml+xml content type as well as tex…

…t/html
  • Loading branch information...
1 parent 35e057c commit 6844b1c55fbf0b206cb6821e01e6976fa007a0a2 @mwrock committed May 29, 2012
View
26 RequestReduce.Facts/Module/RequestReduceModuleFacts.cs
@@ -47,6 +47,32 @@ public void WillGetAndSetResponseFilterIfHtmlContent()
}
[Fact]
+ public void WillGetAndSetResponseFilterIfXHtmlContent()
+ {
+ var module = new RequestReduceModule();
+ var context = new Mock<HttpContextBase>();
+ var config = new Mock<IRRConfiguration>();
+ config.Setup(x => x.SpriteVirtualPath).Returns("/Virtual");
+ context.Setup(x => x.Items.Contains(ResponseFilter.ContextKey)).Returns(false);
+ context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
+ context.Setup(x => x.Response.ContentType).Returns("application/xhtml+xml");
+ context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
+ context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
+ RRContainer.Current = new Container(x =>
+ {
+ x.For<IRRConfiguration>().Use(config.Object);
+ x.For<IHostingEnvironmentWrapper>().Use(new Mock<IHostingEnvironmentWrapper>().Object);
+ x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
+ });
+
+ module.InstallFilter(context.Object);
+
+ context.VerifyGet(x => x.Response.Filter, Times.Once());
+ context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Once());
+ RRContainer.Current = null;
+ }
+
+ [Fact]
public void WillNotSetResponseFilterIfFaviconIco()
{
RRContainer.Current = null;
View
3 RequestReduce/Module/RequestReduceModule.cs
@@ -295,7 +295,8 @@ public void InstallFilter(HttpContextBase context)
{
RRTracer.Trace("Entering Module");
var request = context.Request;
- if (context.Response.ContentType != "text/html" ||
+ if ((context.Response.ContentType != "text/html" &&
+ context.Response.ContentType != "application/xhtml+xml") ||
request.RawUrl == "/favicon.ico" ||
IsInRRContentDirectory(context))
return;

0 comments on commit 6844b1c

Please sign in to comment.