---
title: header.get
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/headers/header-get
---

```
STRING header.get(ID where, STRING header_name)
```

**Available in:** all subroutines

Gets a header value by name.
This is equivalent to reading the `req.http.xyz` style variables except that the header name
is given as a string, and may be passed dynamically.
Header names are case insensitive.

The _where_ argument is one of the literal identifiers `req`, `resp`, `obj`,
`bereq`, or `beresp`, corresponding to the [predefined
variable](https://www.fastly.com/documentation/reference/vcl/variables/) of the same
name. The predefined variable associated with the _where_ argument must be
writable within the VCL subroutine where `header.get()` is called.

```vcl
set resp.http.xyz = header.get(req, "user-agent");
```

is equivalent to:

```vcl
set resp.http.xyz = req.http.user-agent;
```

See also the [client request](https://www.fastly.com/documentation/reference/vcl/variables/client-request/req-http/),
and other [request and response](https://www.fastly.com/documentation/reference/vcl/variables/) variables.

Calling `header.get()` for a header which does not exist, or passing the empty string,
a _not-set_ value, or a string that would be invalid as a header name,
causes `header.get()` to return a _not-set_ value.

See `header.set()` for valid characters in header names.
