I have a module that oftentimes needs to use a subrequest in order to
finish sending the response.
If I create the subrequest via ap_sub_req_lookup_uri(), then add a
"Range" header to sr->headers_in, this appears to work ok if my
subrequest is destined for mod_proxy. I believe this is because
mod_proxy just passes all the headers through, and the backend server is
actually doing the byterange work for me.
If I have the same situation, but the subrequest is being serviced by a
local file, the byterange filter won't run even if I explicitly add it
in the chain via ap_add_output_filter(). As far as I can tell, the
filter gets added to sr->proto_output_filters, but not
sr->output_filters like a normal request. I'm assuming this is because
the response has already started, and thus the headers have already been
sent.
I understand that there could be certain situations where I can't rely
on the byterange filter, but I don't believe I would encounter them in
my application. Is there any way to get this to work, or am I doing
something totally wrong? Here's an example of the code I'm using:
//byte_range contains a valid bytes=X-Y value
request_rec* sub_request = ap_sub_req_lookup_uri(r->uri, r, NULL);
ap_add_output_filter("BYTERANGE", NULL,
sub_request, sub_request->connection);
apr_table_set(sub_request->headers_in, "Range", byte_range);
ap_run_sub_req(sub_request);
Thanks,
Mike