.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "VMOD_HEADER" 3 "" "" "" .SH NAME vmod_header \- Header VMOD for Varnish .\" . .\" NB: This file is machine generated, DO NOT EDIT! . .\" . .\" Edit ./vmod_header.vcc and run make instead . .\" . .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import header [as name] [from "path"] VOID append(HEADER, STRING) VOID copy(HEADER, HEADER) STRING get(HEADER header, REGEX regex) VOID remove(HEADER header, REGEX regex) VOID regsub(HTTP, REGEX regex, STRING sub, BOOL all) HEADER dyn(HTTP, STRING) .ft P .fi .UNINDENT .UNINDENT .SH DESCRIPTION .sp Varnish Module for manipulation of duplicated HTTP headers, for instance multiple Set\-Cookie headers. .\" vcl-start . .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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\(aqt really need it. header.remove(beresp.http.Set\-Cookie, "JSESSIONID="); } } .ft P .fi .UNINDENT .UNINDENT .\" vcl-end . .SS VOID append(HEADER, STRING) .INDENT 0.0 .TP .B Description Append an extra occurrence to an existing header. .TP .B Example :: header.append(beresp.http.Set\-Cookie, "foo=bar") .UNINDENT .SS VOID copy(HEADER, HEADER) .INDENT 0.0 .TP .B Description Copy all source headers to a new header. .TP .B Example :: header.copy(beresp.http.set\-cookie, beresp.http.x\-old\-cookie); .UNINDENT .SS STRING get(HEADER header, REGEX regex) .INDENT 0.0 .TP .B Description Fetches the value of the first \fIheader\fP that matches the given regular expression \fIregex\fP\&. .TP .B Example :: set beresp.http.xusr = header.get(beresp.http.set\-cookie,"user="); .UNINDENT .SS VOID remove(HEADER header, REGEX regex) .INDENT 0.0 .TP .B Description Remove all occurrences of \fIheader\fP that matches \fIregex\fP\&. .TP .B Example :: header.remove(beresp.http.set\-cookie,"^(?!(funcookie=))"); .UNINDENT .SS VOID regsub(HTTP, REGEX regex, STRING sub, BOOL all=0) .INDENT 0.0 .TP .B Description For every header line in the HTTP object, which can be one of \fBreq\fP, \fBresp\fP, \fBbereq\fP or \fBberesp\fP, if the line matches the regular expression \fBregex\fP, then replace it with the result of a substitution using the string \fBsub\fP\&. \fBsub\fP may include backreferences of the form \fB\e1\fP through \fB\e9\fP, which refer to capturing expressions in the \fBregex\fP, or \fB\e0\fP to refer to the entire matched portion of the header line. .sp If \fBall\fP is \fBfalse\fP, replace the first matched portion of the header line with \fBsub\fP\&. This is the same operation performed by the VCL native function \fBregsub()\fP\&. \fBall\fP is \fBfalse\fP by default. .sp If \fBall\fP is \fBtrue\fP, replace each non\-overlapping matched portion of the header line with \fBsub\fP\&. This is the same operation performed by native \fBregsuball()\fP\&. .sp Note that unlike the other functions in this VMOD, \fBregsub()\fP applies to the \fIentire\fP header line, including the header name, colon separator, and header value. Take care that your substitutions result in valid headers, since ill\-formed headers can interfere with the HTTP protocol. .sp Consider case sensitivity in the regex match. The standard dictates 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 \fBregex\fP using the \fB(?i)\fP flag, as shown in the example below (use \fB(?\-i)\fP to turn it off). .sp Consider using the \fB^\fP starting anchor in \fBregex\fP to be sure to match a header name (and not the same string somewhere in the middle of the line). .TP .B Example :: header.regsub(req, "^(?i)Foo(\ed): (?\-i)bar=(.*)$", "Bar\e1: \e2") .UNINDENT .SS HEADER dyn(HTTP, STRING) .INDENT 0.0 .TP .B Description Return a dynamic header name. .sp Most other functions of this vmod require a \fIHEADER\fP argument, which usually is a VCL\-defined header like \fBreq.http.foo\fP\&. .sp This function allows to construct a header name from an arbitrary string, which may also be dynamically created, for example from a variable. .sp \fINotice\fP that there are no syntactic checks on the \fISTRING\fP argument by purpose in order to support exotic use cases. It is entirely up to the user and at their own risk to supply a string which represents a valid HTTP header name (or not). .TP .B Example :: # create this request header # 42: is the answer header.append(header.dyn(req, 35 + 7), "is the answer"); .UNINDENT .SH ACKNOWLEDGEMENTS .sp The development of this plugin was made possible by the sponsorship of Softonic, \fI\%http://en.softonic.com/\fP . .sp Also thanks to Imo Klabun and Anders Nordby for bug reports. .SH BUGS .sp You can\(aqt use dynamic regular expressions, which also holds true for normal regular expressions in regsub(). .\" Generated by docutils manpage writer. .