You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by TO...@aol.com on 2000/08/17 19:09:34 UTC
Re: [PATCH] ap_add_filter ( oops )
Oops...
Hit transmit key too early by accident while I was typing
on previous message...
Example of 'Santa Claus' installation approach should
have been this...
if (r->chunked) {
/* Check and see if the filter we want to add ( and whatever */
/* filters that filter wants to install ) is all going to succeed */
/* before we alter the processing chain... */
if ( ap_add_filter("CHUNK", -1, r, NULL ) {
/* Yes... the filter we want WILL install OK so go ahead */
/* and touch the headers and do the REAL install... */
apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked");
apr_table_unset(r->headers_out, "Content-Length");
ap_add_filter("CHUNK", NULL, r, NULL);
}
else {
/* The filter that we wanted to add has something wrong with */
/* it and the ap_add_filter() call returned an error. Since */
/* we have only issued a 'check once' call so far then no */
/* harm done. The output headers haven't been touched yet. */
/* Just continue normally without that filter... */
}
}
Notice that either a new parameter is need for the ap_add_filter()
call which tells it to just 'check' and see if all is OK and
return PASS or FAIL... or you need to establish a special value
for one of the existing parameters to indicate this is just
a 'do nothing but see if it will succeed' call.
I used '-1' for ctx above as the 'check only' indicator.
There are MANY API's that use this 'Check it first and then make
the real call' approach. Sometimes ( Like the entire Microsoft
Multimedia SDK ) the first call kills 2 birds with one stone.
It not only tells you if what you want to do is going to be
possible given the current MM filtering chain... it also returns
the 'sizeof' certain structures that you need to know about
before you do the 'real' insertion call.
As with the 'insert after' approach... the 'Check it first' call
approach will be immediately familiar to developers and
make perfect sense.
Yours...
Kevin Kiley
CTO, Remote Communications, Inc.
http://www.RemoteCommunications.com
http://www.rctp.com - Online Internet Content Compression Server