Hello, I have to code a mod_perl handler for apache 1.x that supports partial file downloads. Apache::Archive doesn't bother with partial downloads at all. Apache::PAR::Static claims it supports them, but it looks it doesn't - it always returns 200 status code. Here is how it handles serving content:
#$contents is content of entire file we are asked for, not a p +art of it! $r->set_content_length(length($contents)); if((my $status = $r->meets_conditions) eq OK()) { $r->send_http_header if ($mod_perl::VERSION < 1.99); } else { return $status; } return OK() if $r->header_only; my $range_request = ($mod_perl::VERSION < 1.99) ? $r->set_byte +range : 0; if($range_request) { while(my($offset, $length) = $r->each_byterange) { $r->print(substr($contents, $offset, $length)) +; } } #I've also tried adding "return 206;" here. Apache still retur +ns status code 200 else { $r->print($contents); } return OK();
Here are headers I'm getting when fetching document served by handler doing the same:
HTTP/1.1 200 OK Date: Fri, 08 Jan 2010 22:06:46 GMT Server: Apache/1.3.33 (Unix) mod_perl/1.29 PHP/5.2.10 Accept-Ranges: bytes Last-Modified: Fri, 08 Jan 2010 20:35:02 GMT Connection: close Content-Type: text/html
Here what headers same Apache returns when serving a part of some static file:
HTTP/1.1 206 Partial Content Date: Fri, 08 Jan 2010 21:25:23 GMT Server: Apache/1.3.33 (Unix) mod_perl/1.29 PHP/5.2.10 Last-Modified: Thu, 14 Feb 2002 17:33:24 GMT ETag: "1ea-23908b-3c6bf4e4" Accept-Ranges: bytes Content-Length: 147241 Content-Range: bytes 2183522-2330762/2330763 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html
So the questions - is it possible to serve partial http requests in mod_perl handlers? If yes, can you give a hint on what module does it (in order to see how it implements it)? The biggest problems I see is forcing apache to return proper status code and accept my Content-Range headers. Thanks in advance for your answers!

In reply to mod_perl handler inside apache 1.x serving partial content - is this possible? How? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.