Consuming response headers in Apache Output filter
Asked Answered
D

0

6

I am writing an apache module output filter that needs to consume a couple of internal-only response headers. These response headers are set by a perl based application running in the backend. The APR function I am using in my output filter is:

apr_table_get(r->headers_out, "x-my-response-header");

However, what seems to happen is that in my output filter I do not see the above response header set, up until the third or fourth bucket brigade - which is unfortunately already too late - I actually need to use the value of x-my-response-header to compute a new response header and set that in the response to the browser.

I insert my output filter this way:

ap_hook_insert_filter(insertOutputFilterHook, NULL, NULL, APR_HOOK_FIRST);
ap_register_output_filter(myFiltersName, myOutputFilter, NULL, AP_FTYPE_CONTENT_SET);

What I have verified:

  • The internal-only headers do appear on the HTTP response on my browser (haven't unset them yet)
  • The first two bucket brigade's buckets contain html page text

Questions:

  • What could be the reasons for why the internal-only response header not be set/visible in the first call to my output filter / first bucket brigade?
  • Is it possible to instead accumulate the first few bucket brigades and then start flushing them out once the internal only response header's value known?
Dolabriform answered 6/7, 2015 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.