Flow action set-headers

A set-headers action dynamically registers multiple HTTP response headers to be sent to the client.

The XSL transformation defined in the xslt attribute is used to generate one or more set-header actions. The generated set-header actions are executed sequentially. The XSL transformation uses fit://request/request as its input DOM. It contains the client‘s incoming request with all headers and parameters. If you need other data sources in your transformation, use the document function, e.g. document('fit://request/dc').

Syntax

  • xslt="..." the path of the xslt file to use (required)
  • xslt-cache="..." whether the compiled XSL transformation should be cached. Defaults to true. Cache usage depends on the FIT_XSLT_USE_CACHE setting in fit.ini.

Usage

More usage examples can be found in the documentation of the set-header action.

<flow>
   <default-request />
   <set-headers xslt="../actions/headers.xsl" xslt-cache="false" />
   <parse />
</flow>

Where the fit://site/actions/headers.xsl contains the XSLT code

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="*">
      <set-headers>
         <set-header name="Bar" value="BAZ" />
         <set-header name="Bar" xpath="string('Quux')" replace="true" />
         <set-header name="Baz" value="{/request/@url}" replace="true" />
      </set-headers>
   </xsl:template>
</xsl:stylesheet>