# headers

## Purpose

Obtains the value of a named header

## Examples

Reading a header's value:

    Format?  <g:header name="Content-Type" />

Or testing for existence:

    <g:if test="${header(name:'User-Agent')}">Hello</g:if>

## Description

Attributes

- `name` - The name of the header

## Source

Show Source

    def header = { attrs ->
            if (attrs.name) {
                def hdr = request.getHeader(attrs.name)
                if (hdr) out << hdr
            }
        }