Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: mod_sed 1.0.2 available :: input/output content filter |
|
Author |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Mon 30 Jun '08 20:31 Post subject: mod_sed 1.0.2 available :: input/output content filter |
|
|
Module mod_sed by Basant Kukreja (Sun Microsystems) is now available at the Apache Download page.
Basant has now also a blog, see http://blogs.sun.com/basant/entry/using_mod_sed_to_filter
Updated on 21 September 2008 to version 1.0.2.
Changes between 1.0.1 and 1.0.2
Fixed following 3 types of warnings :
* warning: array subscript has type 'char'
* warning: suggest parentheses around assignment used as truth value
* warning C4018: '<' : signed/unsigned mismatch
Enjoy,
Steffen
What is mod_sed
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/
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 |
|
admin Site Admin
Joined: 15 Oct 2005 Posts: 692
|
Posted: Sun 21 Sep '08 13:47 Post subject: |
|
|
Updated today to version 1.0.2
Steffen |
|
Back to top |
|
sebastian
Joined: 21 Oct 2008 Posts: 1
|
Posted: Tue 21 Oct '08 21:55 Post subject: |
|
|
What does this mean:
httpd: Syntax error on line 29 of /etc/httpd/httpd.conf: Cannot load /usr/lib/apache2/mod_sed.so into server: /usr/lib/apache2/mod_sed.so: invalid ELF header
?
I guess linux and windows version of the same .so module is not compatible, so could someone compile the mod_sed.so for linux for me? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 11 Nov '08 19:09 Post subject: |
|
|
Yepp, you are right windows modules are different. Can't you compile it yourself?
Source is http://src.opensolaris.org/source/xref/webstack/mod_sed/
To compile the mod_sed, use the apxs tool provided by apache :
Code: |
$ apxs -c mod_sed.c regexp.c sed0.c sed1.c
|
apxs will typically generate the mod_sed.so in .libs directory. |
|
Back to top |
|
|
|
|
|
|