httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: 'Range: bytes=' request with starting byte greater than size of f ile
Date Fri, 10 Sep 1999 16:34:10 GMT
On Fri, 10 Sep 1999, Life is hard, and then you die. wrote:

> One day, Greg Stein wrote:
> > 
> > Oh, heck. There are two range thingies. Content-Range: and Range:.
> > Well... I've got some studying to do :-). In any case, what I'm asking
> > for is that the Apache core supports byte ranges on GET, and I'll bash
> > away on the PUT case. This will be very nice for DAV clients, as they
> > could then operate on reading/writing portions of resources rather than
> > the whole bloody thing.
> Apache already supports byte ranges on GET, as long as the resource
> resolves to a file. For other things trying to support it in the core
> becomes tricky at best. You'd have to invoke the handler and intercept
> the output, possibly buffering it (think
> "bytes=15000-20000,0-20,17000-23000" - well, ok, the ordering
> constraint for the output is only a SHOULD so we could reorder the
> ranges to be strictly increasing and merge overlapping ranges, and we'd
> still be conditionally compliant).
> Streams would make this easier, btw...

hmm, a layer sounds nifty, but it doesn't work -- streams are sequential,
so at a minimum you'd be doing read() and skipping bytes.  But byte ranges
don't have to be in increasing order, so you might need to go backwards...
you really need seek().

in mod_mmap_static i just cloned the code from the core, it's not really a
lot of code: 

    rangestatus = ap_set_byterange(r);

    if (!r->header_only) {
        if (!rangestatus) {
            ap_send_mmap (match->mm, r, 0, match->finfo.st_size);
        else {
            long offset, length;
            while (ap_each_byterange(r, &offset, &length)) {
                ap_send_mmap(match->mm, r, offset, length);

could be generalised with a function pointer

    (*send)(void *, request_rec *, off_t, off_t);


View raw message