diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-02-13 14:42:26 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-02-13 14:49:44 +0200 |
commit | 49ab7b5fa7843a77605b91adf8a3689794fc091a (patch) | |
tree | a66112caaaf9fe883ce449c788df1a8480594db9 /doc/vmod-dbrw.texi | |
parent | 7eb61c964c74af1bafb948584c0404208c9467b8 (diff) | |
download | vmod-dbrw-49ab7b5fa7843a77605b91adf8a3689794fc091a.tar.gz vmod-dbrw-49ab7b5fa7843a77605b91adf8a3689794fc091a.tar.bz2 |
Implement two new flags and a special req.http header to indicate errors
* NEWS: Document changes.
* doc/vmod-dbrw.3: Likewise.
* doc/vmod-dbrw.texi: Likewise.
* configure.ac: Version 2.4.90
* src/dbrw.h (dbrw_config): New member: match_type
* src/vmod_dbrw.c (parse_flags): Handle "eq" and "regex" flags.
(findmatch): Handle the "eq" flag.
(do_rewrite): Return error code.
(vmod_rewrite): Set the X-VMOD-DBRW-Error header on errors.
* tests/atlocal.in (at_vcl_backend): Special handling for
X-VMOD-DBRW-Error.
* tests/initdb.at: Test the 'eq' flag.
* tests/rewrite07.at: New testcase.
* tests/Makefile.am: Add new testcase.
* tests/testsuite.at: Likewise.
Diffstat (limited to 'doc/vmod-dbrw.texi')
-rw-r--r-- | doc/vmod-dbrw.texi | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/doc/vmod-dbrw.texi b/doc/vmod-dbrw.texi index 734dadb..6a987ed 100644 --- a/doc/vmod-dbrw.texi +++ b/doc/vmod-dbrw.texi @@ -132,7 +132,14 @@ for substituting default values and invoking built-in functions during the expansion of the query. @xref{Expansions}, for a detailed description of these. +@anchor{X-VMOD-DBRW-Error} +@vindex X-VMOD-DBRW-Error Having undergone expansions, the query is sent to the database server. +If the query returns no records or if an error occured, @code{rewrite} +returns empty string. In case of error, it also sets the HTTP header +@samp{X-VMOD-DBRW-Error: 1}. It can be used in VLC code to provide a +special handling for such failures. + The returned set of records (if non-empty) is processed depending on the number of fields it contains. @@ -166,7 +173,7 @@ resulting value is then returned to the caller. @cindex flags @anchor{flags} Optional @var{flags} column is a comma-separated list of flags that -modify regular expression handling: +control the matching algorithm. @table @samp @kindex NC @@ -183,6 +190,11 @@ Treat @var{regexp} as case-insensitive regular expression. @item case Treat @var{regexp} as case-sensitive (default). +@kindex eq +@cindex exact matching +@item eq +Use exact string matching. + @kindex QSA @kindex qsappend @cindex query string handling @@ -209,6 +221,12 @@ the original @var{value}. @item R=@var{code} On success, set the @samp{X-VMOD-DBRW-Status} header to @var{code}, which must be a valid HTTP status code. + +@kindex regex +@cindex regular expression matching +@item regex +Use regular expression matching. This is the default. This flag is +provided for completeness sake, as a counterpart of @samp{eq}. @end table If @var{regexp} or @var{value} is NULL, strict matching is assumed @@ -701,6 +719,24 @@ The @code{X-VMOD-DBRW-Status} header, if set, contains the status code to be returned to the client (@pxref{X-VMOD-DBRW-Status}). Notice the use of the @command{vmod_std} module to cast it to integer. +If an error occured during the rewrite, it is recommended to not +cache the response. This way the next request will call rewrite again +and eventually complete the rewriting. This can be achieved using the +following @code{vcl_backend_response} fragment: + +@example +@group +sub vcl_backend_response +@{ + if (bereq.http.X-VMOD-DBRW-Error == "1") @{ + set beresp.uncacheable = true; + return (deliver); + @} +@} +@end group +@end example + + @node Reporting Bugs @chapter How to Report a Bug |