Pre- and Post-Processing
As with an origin server, it may be necessary to preprocess data
before the main content-transforming filter, and/or postprocess afterwards.
For example, when dealing with gzipped content we need to uncompress it
for processing and re-compress the processed data. Similarly in an
image-processing filter, we need to decode the original image format
and re-encode the processed data.
This may involve more than one phase. For example, when filtering
text, we may need to both to uncompress gzipped data and transcode the
character set before the main filter.
So, potentially we have a large multiplicity of filters: transformation
filters, together with pre- and post-processing for different content
types and encodings. To repeat the hack of having each filter inserted
and determining whether to run or remove itself in such a setup goes
beyond simple inelegance and into the absurd. An alternative architecture
is required.