Close the stream for remote resources

Nov 24, 2009 at 5:16 PM

When i was trying to implement Js filter simiar to Css filter i noticed that the stream reader is not closed for the remote resources in RequestProcessor.cs, method ReadResourceContent. I changed like below, also you can fix this for the next release.

using (var stream = webClient.OpenRead(absoluteUrl))
   {
   	var reader = new StreamReader(stream, Encoding.UTF8);
         return reader.ReadToEnd();
   }
I really appreciate your commitment.
Nov 25, 2009 at 4:36 AM

@rgrajan: thanks a lot of reporting this issue.  I've addressed it in the latest code commit. It looks as follows:

 

using (var webClient = new WebClient())
{
    if (resource.ForwardCookie)
        webClient.Headers["Cookie"] = Context.Request.Headers["Cookie"];
    webClient.Encoding = Encoding.UTF8;
    return webClient.DownloadString(absoluteUrl);
}