IIS 7 and Above
URL Rewrite Module
Outbound rules not updating 'Content-Length' header
Last post Jan 18, 2012 03:39 PM by nsalhaji
Dec 15, 2010 07:22 PM|grayhaze|LINK
A couple of months back I posted about an issue that I was having with getting the URL Rewrite module working with ColdFusion 9 when defining outbound rules (http://forums.iis.net/p/1172116/1959782.aspx).
Unfortunately nobody was able to help me, so I continued researching into a potential solution.
After much digging around in log files and examining responses using Fiddler, I found that ColdFusion passes response data to IIS with a 'Transfer-Encoding' of 'chunked'. This in itself shouldn't have caused problems for the URL Rewrite module, as I have
read in various places that the module is able to handle chunked data. There is no compression (static or dynamic) enabled on the server for the site in question, so this also wasn't the issue.
As a test, I forced ColdFusion to add a 'Content-Length' header to its response, which basically disabled chunking by telling IIS, and in turn the browser, how much data to expect. Somehow this enabled me to get outbound rules working, which suggested to
me that either the module doesn't handle chunked responses correctly, or ColdFusion serves up these chunks in a way other than that expected by the module and/or IIS.
Despite this breakthrough, this has now created another problem. When the module rewrites URLs in the page, it is leaving the 'Content-Length' header in tact and not altering the value in any way. This has the effect of correctly rewriting the URLs and serving
the result to the browser, but the browser either hangs while it waits for more data or ignores any data after the length set in the header, depending on whether the result of the rewrite is shorter or longer than the original.
For example, if I write a rule which will change an instance of 'http://www.mysite.com/test.cfm' to 'http://www.mysite.com/test', the browser will start to load the page (and in some cases display the content that the server passes) and then hang while it
waits for four more bytes of data.
Similarly, if I write a rule which changes an instance of 'http://www.mysite.com/test.cfm' to 'http://www.mysite.com/my-test-page', the browser will load the page without hanging and seems to render correctly, but when I view the source it has trimmed/ignored
the last four characters of the HTML (ie. the source will end with the characters '</h', not '</html>').
Does anyone have any idea how I can force the rewrite module to update the 'Content-Length' header with the correct value post-replacement? Alternatively, if anyone has any further insight into why the module might fail when presented with ColdFusion's idea
of a chunked response, then this would also be very helpful!
Apr 18, 2011 06:19 PM|xxyyzz|LINK
I have the same issue with the Content-Length not being updated after a rewrite.
Does anyone have any ideas?
May 11, 2011 04:49 PM|borota|LINK
In InetMgr you need to Server Node -> Application Request Routing Cache -> Server Proxy Settings and increase Buffer Setting.
You will see that issue happens only when Response buffer threshold is reached.
Jan 18, 2012 03:39 PM|nsalhaji|LINK