Andy Grundman wrote:
> I am writing a secure download ResponseHandler that sends a file to the
> user.  I have simple sends working fine with sendfile($filename) but I
> also need to handle 206 Partial Content as the files I'm dealing with
> are big and may need to be resumed.

byteserving in apache 2.0 is handled by the byterange output filter, similar
to the way it handles Content-Length, chunked encoding, etc, regardless of
who is generating the content.  I'm very surprised you need to deal with
byteserving on your own - did you issue a Range request and Apache didn't
respond with a partial response?


> $r->headers_out->set('Content-Length' => $size);

don't do that - use $r->set_content_length()

>     * arg3: $offset (string)

that's an apr_off_t, not a string.  apr_off_t is essentially an int.

>     * arg4: $len (integer)
>     * ret: $ret (integer)
> 
> What gets me is, why is offset listed as a string and not an integer? Is
> it not an offset in bytes?  My first thought is maybe this is an offset
> in hex because it did work for the first part of the file but stopped
> later in the fille as if it was trying to seek beyond the end of the file.
> 
> I know the offset value is being transposed to something at least,
> because I did a test download using several 206 requests, and the
> resluting file had gaps in it where it was resumed instead of being
> seamless.
> 
> Does anyone know anything about sendfile or offset in mp2?  I am running
> Apache 2.0.48, mod_perl 1.99_10, with Perl 5.8.2 on Gentoo.

again, I'm surprised you need to deal with this yourself - the byterange
filter should really take care of everything for you.  heck, the old
ap_set_byterange and ap_each_byterange API from 1.3 that allowed you to
handle this yourself isn't even public anymore in 2.0 - ap_each_byterange is
gone entirely and ap_set_byterange is now private to http_protocol.c (and
used only in the byterange filter):

  static int ap_set_byterange(request_rec *r)

HTH

--Geoff




-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to