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
86d6a633
Commit
86d6a633
authored
Mar 28, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for the extract() method to vcl_regex.vtc
parent
f822f73c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
2 deletions
+52
-2
vcl_regex.vtc
src/tests/vcl_regex.vtc
+52
-2
No files found.
src/tests/vcl_regex.vtc
View file @
86d6a633
...
@@ -106,7 +106,7 @@ varnish v1 -vcl {
...
@@ -106,7 +106,7 @@ varnish v1 -vcl {
client c1 -run
client c1 -run
# sub()
function
# sub()
method
varnish v1 -vcl {
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
...
@@ -164,7 +164,7 @@ client c2 {
...
@@ -164,7 +164,7 @@ client c2 {
expect resp.http.regsuballsub == "barbazbar"
expect resp.http.regsuballsub == "barbazbar"
} -run
} -run
# suball()
function
# suball()
method
varnish v1 -vcl {
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
...
@@ -213,3 +213,53 @@ varnish v1 -vcl {
...
@@ -213,3 +213,53 @@ varnish v1 -vcl {
}
}
client c2 -run
client c2 -run
# extract() method
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new barbaz = re2.regex("(bar)baz");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.foo = "barbaz";
if (!barbaz.match(resp.http.foo)) {
set resp.status = 999;
}
if (resp.http.foo ~ "bar(baz)") {
set resp.http.tilde =
barbaz.extract(resp.http.foo, "\0\1",
"tildesub");
} else {
set resp.status = 999;
}
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg =
barbaz.extract(resp.http.foo, "\0\1", "negsub");
} else {
set resp.status = 999;
}
set resp.http.regsub
= regsub(resp.http.foo, "bar(baz)", "\1");
set resp.http.regsubsub = barbaz.extract(resp.http.foo, "\0\1",
"regsubx");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuballsub = barbaz.extract(resp.http.foo,
"\0\1",
"regsuballx");
}
}
client c2 -run
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