mwrock / RequestReduce

Instantly makes your .net website faster by reducing the number and size of requests with almost no effort.
www.requestreduce.org
Apache License 2.0
228 stars 49 forks source link

Null Ref in ResponseFilter when RequestReduce and WebAPI and RR are installed #238

Open akcoder opened 11 years ago

akcoder commented 11 years ago

We have some new services implemented with WebAPI. If those services set the ContentType of the response message to anything, except "text/html" everything works fine. However, when the content type is set to "text/html" we get a Null Ref Ex in RR.

I'm going to try and dig in and figure out what the cause is, but thought I would report the issue in the mean time.

RequestReduce: v1.8.76.0 System.Web.Http: v4.0.20710.0 System.Web.Http.WebHost: v4.0.20710.0 WebActivator: v1.5.3.0 Microsoft.Web.Infrastructure: v1.0.0.0

-dan

System.NullReferenceException: Object reference not set to an instance of an object. at RequestReduce.Module.ResponseFilter.Close() in c:\RequestReduce\RequestReduce\Module\ResponseFilter.cs:line 102 at System.Web.HttpWriter.Filter(Boolean finalFiltering) at System.Web.HttpResponse.FilterOutput() at System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

akcoder commented 11 years ago

Upon further investigation, I've determined its because BaseStream is null. On line 52 of RRContainer, if HttpContext.Current is null, then a new ResponseFilter is created, with a null context, and null stream.

However, nothing in ResponseFilter checks if BaseStream is null before performing operations on it.