Re: Question on sub requests and output filter context.
On 19/09/2011 16:48, Nick Kew wrote: On Thu, 15 Sep 2011 11:52:38 +0100 Martin Townsend wrote: Should this new filter also inherit the output filters context? Am I doing something wrong with my use of mod_include? I've tried moving my filter so it's after mod_include but still the same problem. This looks reminiscent of https://issues.apache.org/bugzilla/show_bug.cgi?id=17629 a bug that lurked a long time before being fixed! I suggest you read that - particularly comment 30 and later, and see if it sheds any light on your problem. Hi, I have a solution to my problem but it seems like a bit of a hack. After looking through the source code I found that the only structure that I could use was the subprocess_env table in the request as this is copied between requests and sub requests. AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r) { rnew->subprocess_env = apr_table_copy(rnew->pool, r->subprocess_env); rnew->headers_out = apr_table_make(rnew->pool, 5); rnew->err_headers_out = apr_table_make(rnew->pool, 5); rnew->notes = apr_table_make(rnew->pool, 5); ... } Maybe a better solution would be to use my modules configuration and then ensure the hash tables are removed using a cleanup handler that is fired at the end of the request. Best Regards, Martin.
Re: Question on sub requests and output filter context.
On Thu, 15 Sep 2011 11:52:38 +0100 Martin Townsend wrote: > Should this new filter also > inherit the output filters context? Am I doing something wrong with my > use of mod_include? I've tried moving my filter so it's after > mod_include but still the same problem. This looks reminiscent of https://issues.apache.org/bugzilla/show_bug.cgi?id=17629 a bug that lurked a long time before being fixed! I suggest you read that - particularly comment 30 and later, and see if it sheds any light on your problem. -- Nick Kew
Re: Question on sub requests and output filter context.
On Mon, 2011-09-19 at 15:57 +0100, Martin Townsend wrote: > 1) In my output filter can I get the context of the main requests > filter > and use this in the sub request. You should be able to find the main request. It is however not clear if the main requests filter chain and the subrequests filter chain are even similiar. Sincerely, Joachim
Re: Question on sub requests and output filter context.
On Thu, 2011-09-15 at 11:52 +0100, Martin Townsend wrote: > Having stepped through with the debugger I can see that the pointer > to > the output filter when processing the main HTML page is different to > the > one when parsing custom tags in SSI pages. This is IMHO expected behavior. Different requests have different filter records. Sincerely, Joachim
Re: Question on sub requests and output filter context.
On Thu, Sep 15, 2011 at 12:52, Martin Townsend wrote: > Hi, > > I have an output filter that parses custom tags to retrieve data from an > application running on the same device. > > Everything was working well until I tried to move some HTML into Server Side > Include pages. Snippet below: > > > > > > > > > The first three commands will populate hash tables that are saved in my > output filters context. > The HTML in the included pages then use custom tags to query the hash tables > but for some reason the hash tables are NULL. > > Having stepped through with the debugger I can see that the pointer to the > output filter when processing the main HTML page is different to the one > when parsing custom tags in SSI pages. Looking through mod_include I can > see it creates a sub request for include and sub requests call > make_sub_request to create a new filter. Should this new filter also > inherit the output filters context? Am I doing something wrong with my use > of mod_include? I've tried moving my filter so it's after mod_include but > still the same problem. > > I'm using Server version: Apache/2.2.19 (Unix) on an ARM board. > > Best Regards, > Martin. > > How do you construct the context of your filter? At the first invokation of the filter or in the init function of the filter? In the second case, it could be that you construct the context twice, the first time in the main request processing and the second time in the subrequest processing. In my opinion, apache uses the same filter structure in both the main and the sub request. In mod_includes apache creates a subrequest, passing f->next to it. Thus, the first filter in the filter chain of the subrequest is the filter succeeding the INCLUDES filter. In my opinion, if you place your filter before the INCLUDES filter, your filter should not be called in the subrequest if yours is a AP_FTYPE_RESOURCE filter. If you place your filter after the INCLUDES filter, the hash tables you mention are not initialised at the time when your filter processes the responses of the includes subrequests. I am not sure of what I'm saying because I have no experience in how mod_includes interacts with other filters. Anyway, I hope this helps. Have a look in server/request.c at make_sub_request. The subrequest inherits the protocol filters of the main request, but not all of the non-protocol output filters of the main request. Maybe you should make your filter a AP_FTYPE_PROTOCOL filter such that it is not removed from the chain by mod_includes. S
Question on sub requests and output filter context.
Hi, I have an output filter that parses custom tags to retrieve data from an application running on the same device. Everything was working well until I tried to move some HTML into Server Side Include pages. Snippet below: The first three commands will populate hash tables that are saved in my output filters context. The HTML in the included pages then use custom tags to query the hash tables but for some reason the hash tables are NULL. Having stepped through with the debugger I can see that the pointer to the output filter when processing the main HTML page is different to the one when parsing custom tags in SSI pages. Looking through mod_include I can see it creates a sub request for include and sub requests call make_sub_request to create a new filter. Should this new filter also inherit the output filters context? Am I doing something wrong with my use of mod_include? I've tried moving my filter so it's after mod_include but still the same problem. I'm using Server version: Apache/2.2.19 (Unix) on an ARM board. Best Regards, Martin.