Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
VMOD_HEADER(3)							VMOD_HEADER(3)

NAME
       vmod_header - Header VMOD for Varnish

SYNOPSIS
	  import header	[as name] [from	"path"]

	  VOID append(HEADER, STRING)

	  VOID copy(HEADER, HEADER)

	  STRING get(HEADER header, STRING regex)

	  VOID remove(HEADER header, STRING regex)

	  VOID regsub(HTTP, STRING regex, STRING sub, BOOL all)

DESCRIPTION
       Varnish	Module	for  manipulation  of duplicated HTTP headers, for in-
       stance multiple Set-Cookie headers.

       Example:

	  vcl 4.0;
	  import header;

	  backend default { .host = "192.0.2.11"; .port	= "8080"; }

	  sub vcl_backend_response {
	      if (beresp.http.Set-Cookie) {
		  # Add	another	line of	Set-Cookie in the response.
		  header.append(beresp.http.Set-Cookie,	"VSESS=abbabeef");

		  # CMS	always set this, but doesn't really need it.
		  header.remove(beresp.http.Set-Cookie,	"JSESSIONID=");
	      }
	  }

   VOID	append(HEADER, STRING)
       Description
	      Append an	extra occurrence to an existing	header.

       Example
	      :: header.append(beresp.http.Set-Cookie, "foo=bar")

   VOID	copy(HEADER, HEADER)
       Description
	      Copy all source headers to a new header.

       Example
	      ::			   header.copy(beresp.http.set-cookie,
	      beresp.http.x-old-cookie);

   STRING get(HEADER header, STRING regex)
       Description
	      Fetches  the  value  of  the first header	that matches the given
	      regular expression regex.

       Example
	      ::	      set	       beresp.http.xusr		     =
	      header.get(beresp.http.set-cookie,"user=");

   VOID	remove(HEADER header, STRING regex)
       Description
	      Remove all occurrences of	header that matches regex.

       Example
	      :: header.remove(beresp.http.set-cookie,"^(?!(funcookie=))");

   VOID	regsub(HTTP, STRING regex, STRING sub, BOOL all=0)
       Description
	      For  every  header  line in the HTTP object, which can be	one of
	      req, resp, bereq or beresp, if the line matches the regular  ex-
	      pression	regex,	then replace it	with the result	of a substitu-
	      tion using the string sub. sub may include backreferences	of the
	      form  \1 through \9, which refer to capturing expressions	in the
	      regex, or	\0 to refer to	the  entire  matched  portion  of  the
	      header line.

	      If all is	false, replace the first matched portion of the	header
	      line with	sub. This is the same operation	performed by  the  VCL
	      native function regsub().	all is false by	default.

	      If  all is true, replace each non-overlapping matched portion of
	      the header line with sub.	This is	the same  operation  performed
	      by native	regsuball().

	      Note  that unlike	the other functions in this VMOD, regsub() ap-
	      plies to the entire header  line,	 including  the	 header	 name,
	      colon separator, and header value. Take care that	your substitu-
	      tions result in valid headers, since ill-formed headers can  in-
	      terfere with the HTTP protocol.

	      Consider	case sensitivity in the	regex match. The standard dic-
	      tates that header	names are case insensitive, but	header	values
	      are  not.	 The VMOD function does	not take care of that for you,
	      but you can express it in	the regex  using  the  (?i)  flag,  as
	      shown in the example below (use (?-i) to turn it off).

	      Consider	using  the  ^  starting	 anchor	in regex to be sure to
	      match a header name (and not the same string  somewhere  in  the
	      middle of	the line).

       Example
	      ::  header.regsub(req,  "^(?i)Foo(\d):  (?-i)bar=(.*)$", "Bar\1:
	      \2")

ACKNOWLEDGEMENTS
       The development of this plugin was made possible	by the sponsorship  of
       Softonic, http://en.softonic.com/ .

       Also thanks to Imo Klabun and Anders Nordby for bug reports.

BUGS
       You  can't  use	dynamic	regular	expressions, which also	holds true for
       normal regular expressions in regsub().

								VMOD_HEADER(3)

NAME | SYNOPSIS | DESCRIPTION | ACKNOWLEDGEMENTS | BUGS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=vmod_header&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help