Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

IIS not responding to HTTP request header added in the Rewrite Module

$
0
0

Hi, I'm having problems getting IIS7.5 to accept HTTP range headers, added using the URL Rewrite module v2

Setting up a DASH server and the players based on Flash pass the byte range data via querystring as the Flash player can't send range headers. These players send a request like http://domain.com/test.mp4?bytes=10-50 A .htaccess file is provided that basically takes the 'bytes=10-50' and puts it into a header. I guess other folks are or will be trying to set this up for DASH on Windows servers as well where .htaccess files don't help much. Anyway this is the file.

<IfModule headers_module>
<IfModule rewrite_module>
  RewriteEngine On
  RewriteCond %{QUERY_STRING} ^(.*)bytes=(.*)$
  RewriteRule ^(.*) - [L,E=range:%2]
  RequestHeader set Range "bytes=%{range}e" env=range
</IfModule>
</IfModule>

First problem is that this file won't import into the IIS Rewrite module, which gives the error: cannot be converted to IIS format because of unsupported flags: E

So as the .htaccess wouldn't import I added HTTP_RANGE to the allowed variable list and created a basic test rule that triggers on anything and just sets a HTTP Range header with some fixed values.

<rewrite>
  <rules>
    <rule name="RangeTest">
       <match url="(.*)" />
        <serverVariables>
          <set name="HTTP_RANGE" value="bytes=0-50" />
        </serverVariables>
        <action type="None" />
    </rule>
  </rules>
</rewrite>

But I just can't get it to work, it's like the range header is being ignored. I have a basic .net page that displays all the incoming request headers and I know the rewrite rule is triggering as I can see that the new header with the correct format has been added. I can also modify other headers, e.g. user-agent no problem.

With curl you can see the problem. Rule disabled and sending the range header via curl works fine as you would expect, a 206 partial content response:

>>curl -v --header "Range: bytes=0-40" http://domain.com/test.mp4

> GET /test.mp4 HTTP/1.1
> User-Agent: curl/7.40.0
> Accept: */*
> Range: bytes=0-40
>
< HTTP/1.1 206 Partial Content
< Content-Type: video/mpeg
< Last-Modified: Tue, 10 Mar 2015 18:18:05 GMT
< Accept-Ranges: bytes
< ETag: "bc93df8d5e5bd01:0"
< Server: Microsoft-IIS/7.5
< X-Powered-By: ASP.NET
< Date: Wed, 11 Mar 2015 09:12:07 GMT
< Content-Length: 41
< Content-Range: bytes 0-40/30200
<

Rewrite rule enabled and I get a 200 response, all the content is returned:

>>curl -v http://domain.com/test.mp4

> GET /test.mp4 HTTP/1.1
> User-Agent: curl/7.40.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: video/mpeg
< Last-Modified: Tue, 10 Mar 2015 18:18:05 GMT
< Accept-Ranges: bytes
< ETag: "bc93df8d5e5bd01:0"
< Server: Microsoft-IIS/7.5
< X-Powered-By: ASP.NET
< Date: Wed, 11 Mar 2015 09:15:27 GMT
< Content-Length: 30200
<

So the rule is triggering, it's adding the header and then IIS is not responding to it. It does the same on .jpg files. Am I missing something obvious here, please point me in the right direction.

Thanks, Jon


Viewing all articles
Browse latest Browse all 2482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>