.\" Man page generated from reStructuredText .\" by the Docutils 0.23 manpage writer. . . .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_accept" "3" "" "" .SH Name vmod_accept \- Accept VMOD .\" . .\" NB: This file is machine generated, DO NOT EDIT! . .\" . .\" Edit ./vmod_accept.vcc and run make instead . .\" . .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX import accept [as name] [from \(dqpath\(dq] new xrule = accept.rule(STRING string) VOID xrule.add(STRING string) VOID xrule.remove(STRING string) STRING xrule.filter(STRING string) .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp accept allows you to sanitize the Accept* headers (mainly Accept, Accept\-Charset and Accept\-Encoding) by specify one fallback string, and then adding valid values: .INDENT 0.0 .INDENT 3.5 .sp .EX sub vcl_init { new rule = accept.rule(\(dqtext/plain\(dq); rule.add(\(dqtext/html\(dq); rule.add(\(dqapplication/json\(dq); } .EE .UNINDENT .UNINDENT .sp You can then use the \fBrule\fP object to filter the headers. The following line will set the accept header to \(dqtext/html\(dq or \(dqapplication/json\(dq if any of them is found in the original header, and will set it to \(dqtext/plain\(dq if neither is found: .INDENT 0.0 .INDENT 3.5 .sp .EX sub vcl_recv { set req.http.Accept = rule.filter(req.http.Accept); } .EE .UNINDENT .UNINDENT .sp accept will ignore any parameter found and will just return the first choice found. More info here: \% .SH API .SS new xrule = accept.rule(STRING string) .sp Create a rule object, setting the fallback string. .SS VOID xrule.add(STRING string) .sp Add \fBstring\fP to the list of valid choices. .SS VOID xrule.remove(STRING string) .sp Remove \fBstring\fP to the list of valid choices. .SS STRING xrule.filter(STRING string) .sp Parse string and try to find a valid choice. The first one found is returned (they are tested in the same order they were added), otherwise, the fallback string is returned. .SH COPYRIGHT .INDENT 0.0 .INDENT 3.5 .sp .EX Copyright (c) 2016 Guillaume Quintard Author: Guillaume Quintard (vmodtool requires this format.) .EE .UNINDENT .UNINDENT .\" End of generated man page.