-
Notifications
You must be signed in to change notification settings - Fork 52
Description
This initially manifested itself by getting 2 calls to the IHttpModule from a single perceived request.
How to reproduce.
- My Rule
return input;
}
public string Name
{
get
{
return "CDNUrlEncode";
}
}
}
2. What happens.
The first request comes in:
If you check the Request you will see the following in the second request.
RequestUrl = /CDN/CC/Plugins/a.1.2.3.4/a.jpg
RawUrl = /CDN/CC/Plugins/a.1.2.3.4/a.jpg
Custom Transform transforms it to the following:
From: /CDN/CC/Plugins/a.1.2.3.4/a.jpg
To: /CDNInternal/CC?remaining=[encoded Plugins/a.1.2.3.4/a.jpg]
This results in a second request coming in reflecting the new rewrite. If you check the Request you will see the following in the second request. The RequestUrl and the RawUrl are the same. Might be a asp.net MVC 5.2 issue.
RequestUrl = /CDNInternal/CC?remaining=[encoded Plugins/a.1.2.3.4/a.jpg]
RawUrl = /CDN/CC/Plugins/a.1.2.3.4/a.jpg
This causes a rewrite to happen again because it matches the original rule. I would think this should cause an infinite look, but it stopped at 2. Did not investigate that further.
Here is the fix:
https://github.com/sethyates/urlrewriter/blob/master/src/RewriterEngine.cs
public class RewriterEngine
{
public void Rewrite()
{
string originalUrl = _httpContext.RequestUrl.PathAndQuery.Replace("+", " ");
...}
}
replace
string originalUrl = _httpContext.RawUrl.Replace("+", " ");
with
string originalUrl = _httpContext.RequestUrl.PathAndQuery.Replace("+", " ");