Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re2
Commits
b8ad16b1
Commit
b8ad16b1
authored
Oct 16, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set.string() and .backend() when no strings or backends were set.
parent
a3a5bbf4
Pipeline
#338
skipped
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
set_retrieve.vtc
src/tests/set_retrieve.vtc
+36
-0
vmod_re2.c
src/vmod_re2.c
+22
-2
No files found.
src/tests/set_retrieve.vtc
View file @
b8ad16b1
...
...
@@ -11,6 +11,10 @@ varnish v1 -vcl {
s.add("foo", "baz");
s.add("bar", "quux");
s.compile();
new n = re2.set();
n.add("foo");
n.compile();
}
sub vcl_recv {
...
...
@@ -38,6 +42,13 @@ varnish v1 -vcl {
set resp.http.s-many-first = s.string(select=FIRST);
set resp.http.s-many-last = s.string(select=LAST);
set resp.http.s-outofrange = s.string(3);
set resp.http.n-str-1 = n.string(1);
set resp.http.n-str-2 = n.string(2);
set resp.http.n-before-match = n.string();
set resp.http.n-foo-match = n.match("foo");
set resp.http.n-foo-n = n.nmatches();
set resp.http.n-foo-str = n.string();
}
} -start
...
...
@@ -66,6 +77,12 @@ client c1 {
expect resp.http.s-many-first == "baz"
expect resp.http.s-many-last == "quux"
expect resp.http.s-outofrange == ""
expect resp.http.n-str-1 == ""
expect resp.http.n-str-2 == ""
expect resp.http.n-before-match == ""
expect resp.http.n-foo-match == "true"
expect resp.http.n-foo-n == 1
expect resp.http.n-foo-str == ""
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
...
...
@@ -75,6 +92,10 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod re2 error: s.string.0.: previous match was unsuccessful$"
expect * = VCL_Error "^vmod re2 error: s.string.0.: 2 successful matches$"
expect * = VCL_Error "^vmod re2 error: s.string.3.: set has 2 patterns$"
expect * = VCL_Error "^vmod re2 error: n.string.1.: No strings were set for n$"
expect * = VCL_Error "^vmod re2 error: n.string.2.: No strings were set for n$"
expect * = VCL_Error "^vmod re2 error: n.string.0.: No strings were set for n$"
expect * = VCL_Error "^vmod re2 error: n.string.0.: No strings were set for n$"
expect * = End
} -run
...
...
@@ -89,6 +110,10 @@ varnish v1 -vcl {
b.add("foo", backend=b1);
b.add("bar", backend=b2);
b.compile();
new n = re2.set();
n.add("foo");
n.compile();
}
sub vcl_recv {
...
...
@@ -116,6 +141,13 @@ varnish v1 -vcl {
set resp.http.b-many-first = b.backend(select=FIRST);
set resp.http.b-many-last = b.backend(select=LAST);
set resp.http.b-outofrange = b.backend(3);
set resp.http.n-backend-1 = n.backend(1);
set resp.http.n-backend-2 = n.backend(2);
set resp.http.n-before-match = n.backend();
set resp.http.n-foo-match = n.match("foo");
set resp.http.n-foo-n = n.nmatches();
set resp.http.n-foo-backend = n.backend();
}
}
...
...
@@ -127,6 +159,10 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod re2 error: b.backend.0.: previous match was unsuccessful$"
expect * = VCL_Error "^vmod re2 error: b.backend.0.: 2 successful matches$"
expect * = VCL_Error "^vmod re2 error: b.backend.3.: set has 2 patterns$"
expect * = VCL_Error "^vmod re2 error: n.backend.1.: No backends were set for n$"
expect * = VCL_Error "^vmod re2 error: n.backend.2.: No backends were set for n$"
expect * = VCL_Error "^vmod re2 error: n.backend.0.: No backends were set for n$"
expect * = VCL_Error "^vmod re2 error: n.backend.0.: No backends were set for n$"
expect * = End
} -start
...
...
src/vmod_re2.c
View file @
b8ad16b1
...
...
@@ -857,7 +857,17 @@ get_match_idx(VRT_CTX, struct vmod_re2_set *set, VCL_INT n, VCL_ENUM selects,
VCL_STRING
vmod_set_string
(
VRT_CTX
,
struct
vmod_re2_set
*
set
,
VCL_INT
n
,
VCL_ENUM
selects
)
{
int
idx
=
get_match_idx
(
ctx
,
set
,
n
,
selects
,
"string"
);
int
idx
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_RE2_SET_MAGIC
);
if
(
set
->
string
==
NULL
)
{
VERR
(
ctx
,
"%s.string(%lld): No strings were set for %s"
,
set
->
vcl_name
,
n
,
set
->
vcl_name
);
return
NULL
;
}
idx
=
get_match_idx
(
ctx
,
set
,
n
,
selects
,
"string"
);
if
(
idx
<
0
)
return
NULL
;
return
set
->
string
[
idx
];
...
...
@@ -866,7 +876,17 @@ vmod_set_string(VRT_CTX, struct vmod_re2_set *set, VCL_INT n, VCL_ENUM selects)
VCL_BACKEND
vmod_set_backend
(
VRT_CTX
,
struct
vmod_re2_set
*
set
,
VCL_INT
n
,
VCL_ENUM
selects
)
{
int
idx
=
get_match_idx
(
ctx
,
set
,
n
,
selects
,
"backend"
);
int
idx
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_RE2_SET_MAGIC
);
if
(
set
->
backend
==
NULL
)
{
VERR
(
ctx
,
"%s.backend(%lld): No backends were set for %s"
,
set
->
vcl_name
,
n
,
set
->
vcl_name
);
return
NULL
;
}
idx
=
get_match_idx
(
ctx
,
set
,
n
,
selects
,
"backend"
);
if
(
idx
<
0
)
return
NULL
;
return
set
->
backend
[
idx
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment