dp:request-header()

Returns the value of a protocol-specific request header.

Namespace declaration

  • XSLT
    xmlns:dp="http://www.datapower.com/extensions"
  • XQuery
    declare namespace dp = "http://www.datapower.com/extensions";

Syntax

dp:request-header(field)

Parameters

field
The xs:string that identifies the header field.

Guidelines

The dp:request-header() function returns the value of the HTTP header. When multiple instances of the same header exist, returns one of the same-named headers.

Compare with the dp:http-request-header() function, which supports only the HTTP protocol.

The extension passes all arguments as XPath expressions.

Results

  • When the header is found, returns an xs:string that contains the value of the header.
  • When the header is not found, returns an empty string.

Examples

  • Capture the input Content-Type header value in an XSLT stylesheet.
    …
    <xsl:variable name="input-contenttype">
      <xsl:choose>
        <xsl:when test="dp:responding()">
          <xsl:value-of select="dp:response-header('Content-Type')"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="dp:request-header('Content-Type')"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    …
  • In an XQuery script.
    declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
    declare namespace dp = "http://www.datapower.com/extensions";
    declare option jsoniq-version "0.4.42";
    declare option output:method   "json";
    
    {
      "request-header" : dp:request-header("extfuns-1"),
      "response-header" : dp:response-header("extfuns-2"),
      "http-request-header" : dp:http-request-header("extfuns-3"),
      "http-response-header" : dp:http-response-header("extfuns-4")
    }