logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mod_sed available: input/output content filter
Author
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Wed 30 Apr '08 17:03    Post subject: mod_sed available: input/output content filter Reply with quote

Thanks to Basant Kukreja (Sun Microsystems) we can make mod_sed available. He has updated the original sed code to be thread-safe and reentrant and to use APR pools.

Mod_sed is a in-process content filter. It can be used with any content whether it is static or dynamic, it doesn't matter. So it will work with html,php, cgi, perl etc.

Unlike its predecessors, like line_edit, it can filter input as well as output, one can filter the POST data too with it. So php input content could also be filtered by mod_sed.

See also the blog from Nick at http://bahumbug.wordpress.com/2008/04/28/sed-in-apache/

Enjoy,

Steffen

Examples:

Adding a output (response) filter
<Directory "/htdocs/tested">
AddOutputFilter Sed html
OutputSed "s/california/CA/g"
OutputSed "s/washington/WA/g"
</Directory>

The above example will replace the string "california" to "CA" and "washington" to "WA" in all html docs in testsed directory before sending to client.

Adding a input (request) filter
Following example adds a input filter to php cgi scripts. Sed scripts will be executed for any POST data to php files.
<Directory "/apache2/cgi-bin">
AddInputFilter Sed php
InputSed "s/california/CA/g"
</Directory>

In the above example, if POST (or even GET in HTTP/1.1) data (not the headers) contains the string "california" then it is replaced with string "CA" before the post data is made available to php script.
Back to top


Reply to topic   Topic: mod_sed available: input/output content filter View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules