request:getHeader

Purpose

Used to access the value of a request header.

If the specified request header exists then its value is returned. If it does not exist, the result depends on whether a default argument was provided. If it was then it is returned as the result of this function, otherwise an empty sequence is returned.

A request header can have more than one value associated with it, for example by repeating the parameter. If this is the case then this function will be equivalent to accessing the first value returned by calling the request:getHeaders function.

Signature

request:getHeader [name, default]

Parameter

Name Description Type Use
name The name of the request header xs:string required 
default The value to return if the request header is not present xs:string optional 

Example

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline">
  <head>
    <title>request:getHeader</title>
  </head>
  <body>
    <p>Request header: <pipeline:value-of expr="request:getHeader('user-agent')"/></p>
  </body>
</html>

Related topics