Outputfilter allows to filter the output and rewrite some part of it (for example headers) before sending it to the client. It is in beta version. Submit your bugs, feature wishes (or any enhancement/mistake in the documentation) here.
For now it only allows to change or add headers, or to change the HTTP code.
To use that extension, load OCamlfind package ocsigenserver.ext.outputfilter, either from your Dune file (if you are using static linking), or from the configuration file:
<extension findlib-package="ocsigenserver.ext.outputfilter"/>
This page describes the configuration file options. If you are building a statically linked executable without configuration file, use the corresponding functions from module Outputfilter.
When you want to rewrite one header (after having generated a page), do something like:
<outputfilter header="location" regexp="http://my.newaddress.org/(.*)" dest="http://my.publicaddress.org/\1"/>
Here we rewrite the content of the header location (this line is useful when you are using the reverse proxy).
When you want to add a header (after having generated a page), do something like:
<outputfilter header="X-Frame-Options" dest="SAMEORIGIN" replace="true"/>
This will add the header "X-Frame-Options" with content "SAMEORIGIN" to the generated page. The replace attribute is optionnal.
The syntax to change the HTTP code is:
<sethttpcode code=... />
where the value of the code attribute is a valid HTTP code (404 or 200 for example).