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

FreeBSD Manual Pages

  
 
  

home | help
VMOD_ACCEPT(3)		    Library Functions Manual		  VMOD_ACCEPT(3)

NAME
     vmod_accept - Accept VMOD

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

	new xrule = accept.rule(STRING string)

	    VOID xrule.add(STRING string)

	    VOID xrule.remove(STRING string)

	    STRING xrule.filter(STRING string)

DESCRIPTION
     accept  allows  you  to  sanitize	the  Accept* headers (mainly Accept, Ac-
     cept-Charset and Accept-Encoding) by specify one fallback string, and  then
     adding valid values:

	sub vcl_init {
	    new rule = accept.rule("text/plain");
	    rule.add("text/html");
	    rule.add("application/json");
	}

     You  can then use the rule object to filter the headers. The following line
     will set the accept header to "text/html" or "application/json" if  any  of
     them  is  found  in the original header, and will set it to "text/plain" if
     neither is found:

	sub vcl_recv {
	    set req.http.Accept = rule.filter(req.http.Accept);
	}

     accept will ignore any parameter found  and  will	just  return  the  first
     choice	found.	   More     info    here:     <https://www.w3.org/Proto-
     cols/rfc2616/rfc2616-sec14.html>

API
   new xrule = accept.rule(STRING string)
     Create a rule object, setting the fallback string.

   VOID xrule.add(STRING string)
     Add string to the list of valid choices.

   VOID xrule.remove(STRING string)
     Remove string to the list of valid choices.

   STRING xrule.filter(STRING string)
     Parse string and try to find a valid choice. The first  one  found  is  re-
     turned  (they are tested in the same order they were added), otherwise, the
     fallback string is returned.

COPYRIGHT
	Copyright (c) 2016 Guillaume Quintard

	Author: Guillaume Quintard <guillaume.quintard@gmail.com>

	(vmodtool requires this format.)

								  VMOD_ACCEPT(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=vmod_accept&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help