Available inall subroutines.
Sets a header by name.
This is equivalent to the
set statement 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
beresp, corresponding to the predefined
variable of the same
name. The predefined variable associated with the where argument must be
writable within the VCL subroutine where
header.set() is called.
header.set(req, "abc", "xyz");
is equivalent to:
set req.http.abc = "xyz";
See also the set statement, the client request, and other request and response variables.
Some headers are protected. These headers cannot be set,
header.set() function has no effect.
See the Header reference
for which headers are protected.
header.set() 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,
also has no effect.
A valid header name consists of one or more of the following characters:
! # $ % & ' * + - . 0-9 A-Z ^ _ ` a-z | ~
This is beyond what's possible to set by the
set resp.http.xyz = ...; syntax because
some of these characters are not permitted in VCL variable names.
For example, it is possible to set a header named
hello! (with the exclamation mark):
header.set(resp, "hello!", "abc"); # in the http response: hello!: abc
which is not possible using the
set resp.http.xyz = ...; syntax.
Leading and trailing whitespace are not permitted in header names.
The maximum length for a header name is 126 characters.