View Single Post

  #7 (permalink)  
Old 02-16-2007
shimmyshack
 
Posts: n/a
Default Re: mod_rewrite & headers

On 15 Feb, 22:45, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 15 Feb, 14:57, "Dave" <spambox.dcc...@gmail.com> wrote:
>
>
>
> > > The part about the GET variables?
> > > Most rewriting is done to get variables, for instance:
> > > http://example.com/foo/bar
> > > Is rewritten internally to:
> > > http://example.com/index.php?foz=foo&baz=bar

>
> > > That's a piece of cake, and usally works. Now what if we're trying this
> > > URL:
> > > http://example.com/foo/bar?foz=var

>
> > > It's highly dependant on the actual rewrite and/or the receiving script
> > > wether this script thinks the GET variable foz is 'var', 'foo', or maybe
> > > both.

>
> > > While POST & HEADER values can be altered, this most be done very
> > > explicitly, so it's very hard to do it by accidant. Not so for the GET.
> > > --
> > > Rik Wasmus

>
> > Rik,

>
> > With you. I won't need to request files with additional values passed
> > on the querystring. So the first example will apply. As long as I can
> > read the requesting header information, then I should be fine.

>
> > Many thanks

>
> > Dave

>
> $_SERVER["HTTP_RANGE"] is what you need, and then you need to send
> back a couple of headers to the application which plays the mpeg:
> for instance here is the RR cycle for a raw mp3:
> GET /readings/listen/esv/February15.mp3 HTTP/1.1
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:
> 1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
> Accept: text/xml,application/xml,application/xhtml+xml,text/
> html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> Keep-Alive: 300
> Range: bytes=417792-
> If-Range: "228f8-3a43cd-708051a3"
>
> HTTP/1.1 206 Partial Content
> Date: Thu, 15 Feb 2007 22:33:25 GMT
> Server: Microsoft-IIS/7.0
> Last-Modified: Wed, 14 Feb 2007 00:01:07 GMT
> ETag: "228f8-3a43cd-708051a3"
> Accept-Ranges: bytes
> Content-Length: 3400653
> Vary: User-Agent
> Content-Range: bytes 417792-3818444/3818445
> Content-Type: audio/mpeg
>
> the user-agent knew the Etag for the mp3, apache responds with this e-
> tag as well as the Content-Range, and Accept-Ranges headers
>
> make sure you generate the right headers with your php script and you
> should be fine, and then of course read from the correct offset!!




I suppose I should add that theres a great resource at http://
www.ampache.com
for instance in the play folder theres a file called index.php which
has these lines:

if ($start) {
debug_event('seek','Content-Range header recieved, skipping ahead ' .
$start . ' bytes out of ' . $song->size,'5');
$browser->downloadHeaders($song_name, $song->mime, false, $song-
>size);

fseek( $fp, $start );
$range = $start ."-". ($song->size-1) . "/" . $song->size;
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes=$range");
header("Content-Length: ".($song->size-$start));
}

I havent determined whether it can handle streaming at just above the
average bit rate, which can be useful, but it seems an active project.
Although some of the code is a work in progress.