LOG IN SIGN UP
Documentation

Isolating header values without regular expressions

Fastly supports the ability to extract header subfield values without regular expressions in a human-readable way.

"Headers subfields" refer to headers with a body syntax style similar to value1=123value123; testValue=asdf_true; loggedInTest=true; or max-age=0, surrogate-control=3600 These headers include Cookie, Set-Cookie, Cache-Control, or a custom header. Fastly allows you to isolate these key values with the following syntax:

req.http.Header-Name:key-name

In cases where a Set-Cookie response from origin is value1=123value123; testValue=asdf_true; loggedInTest=true;, the code for isolating the loggedInTest value would be:

beresp.http.Set-Cookie:loggedInTest

This logic can be used in uploaded custom VCL, as well as throughout the UI. For example, using VCL this logic would execute based on the value of staff_user within req.http.Cookie.

# in vcl_recv
if (req.http.Cookie:staff_user ~ "true") {
  # some logic goes here
  return(pass);
}

For example, to isolate the value of ab_test_value from Cookie to the header req.http.AB-Test-Value in the header configuration UI, set up a custom header with the following settings:

the new header window showing a custom header without regular expressions

Fill out the fields with the following:

This will send the AB-Test-Value header in every inbound request.