Converts the string s to an integer value. The value base must be a constant integer expression or integer-returning function.

The following string formats are supported:

The syntax for integers extends the syntax for VCL INTEGER literals in base 10 and 16 respectively. See VCL Types for details of the INTEGER literal syntax for these bases.

Supported bases are 2 - 36, inclusive and the special value 0. For bases over 10, the alphabetic digits are case insensitive.

A base of 0 causes the base to be automatically determined from the string format. In this case, a 0x prefix indicates hex (base 16), a prefix of 0 indicates octal (base 8), and otherwise the base is taken as decimal (base 10).

When an explicit base is specified, the hexadecimal prefix of 0x and the octal prefix of 0 are not required.

Whitespace and trailing characters are permitted and have no effect on the value produced.

If the base is outside the range, or the number exceeds the range of a signed integer, fastly.error is set to ERANGE. If the number could not be parsed, fastly.error is set to EPARSENUM.

On error, fastly.error is set.


std.strtol(STRING s, INTEGER base)


if (std.strtol(req.http.X-HexValue, 16) == 42) {
  set req.http.X-TheAnswer = "Found";