Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
e39cb41b
Commit
e39cb41b
authored
Oct 22, 2019
by
Denes Matetelki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding string additional assignment (+=) operator
parent
5f039a4a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
6 deletions
+113
-6
b00070.vtc
bin/varnishtest/tests/b00070.vtc
+94
-0
v00018.vtc
bin/varnishtest/tests/v00018.vtc
+0
-5
vcc_action.c
lib/libvcc/vcc_action.c
+19
-1
No files found.
bin/varnishtest/tests/b00070.vtc
0 → 100644
View file @
e39cb41b
varnishtest "Check the += operator on strings"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_deliver {
# NOTE: These are type: HEADER
# existing string assignment
set resp.http.a = "a";
set resp.http.b = resp.http.a + "b";
set resp.http.c = "c";
# new: string addition assinment
set resp.http.c += resp.http.b + "d";
# int += string
set resp.http.i = 1;
set resp.http.i += "i";
set resp.http.k = 2;
set resp.http.k += "k" + 22;
set resp.http.l = 3;
set resp.http.l += 33 + "l";
# string += int
set resp.http.s = "s";
set resp.http.s += 1;
set resp.http.q = "q";
set resp.http.q += "q" + 44;
set resp.http.r = "r";
set resp.http.r += 55 + "r";
set resp.http.t = "t";
set resp.http.t += now;
# NOTE: this is type: STRING
set client.identity = "c1";
set client.identity += "c2";
set resp.http.id = client.identity;
}
# regression testing integer
sub vcl_backend_response {
set beresp.status = 198;
set beresp.status += 2;
set beresp.http.a += beresp.grace;
}
} -start
client c1 {
txreq
rxresp
expect resp.http.a == "a"
expect resp.http.b == "ab"
expect resp.http.c == "cabd"
expect resp.http.i == "1i"
expect resp.http.k == "2k22"
expect resp.http.l == "333l"
expect resp.http.s == "s1"
expect resp.http.q == "qq44"
expect resp.http.r == "r55r"
# NOTE: test somehow:
# expect resp.http.t == "t" + now
expect resp.http.id == "c1c2"
expect resp.status == 200
} -run
# testing type: BODY
varnish v1 -errvcl "Cannot convert BODY to STRING" {
sub vcl_synth {
set resp.body = "body";
set resp.body += "mary";
return (deliver);
}
}
bin/varnishtest/tests/v00018.vtc
View file @
e39cb41b
...
...
@@ -27,11 +27,6 @@ varnish v1 -errvcl {Expected '=' got '+='} {
sub vcl_backend_fetch { set bereq.backend += b; }
}
varnish v1 -errvcl {Expected '=' got '+='} {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { set req.url += now; }
}
varnish v1 -errvcl {Expected ';' got 'if'} {
backend b { .host = "127.0.0.1"; }
/* XXX: This should not really be an synth */
...
...
lib/libvcc/vcc_action.c
View file @
e39cb41b
...
...
@@ -120,8 +120,26 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
type
=
ap
->
want
;
break
;
}
if
(
ap
->
type
==
VOID
)
int
ss
=
0
;
if
(
ap
->
type
==
VOID
&&
tl
->
t
->
tok
==
T_INCR
)
{
if
(
type
==
HEADER
)
{
SkipToken
(
tl
,
T_INCR
);
ss
=
1
;
Fb
(
tl
,
1
,
"VRT_GetHdr(ctx, %s),
\n
"
,
sym
->
rname
);
}
else
if
(
type
==
STRING
)
{
SkipToken
(
tl
,
T_INCR
);
ss
=
1
;
Fb
(
tl
,
1
,
"%s,
\n
"
,
sym
->
rname
);
}
else
if
(
type
==
BODY
)
{
VSB_printf
(
tl
->
sb
,
"Cannot convert BODY to STRING
\n
"
);
}
}
if
(
!
ss
&&
ap
->
type
==
VOID
)
{
SkipToken
(
tl
,
ap
->
oper
);
}
if
(
type
==
HEADER
)
{
vcc_Expr
(
tl
,
STRING_LIST
);
}
else
if
(
type
==
STRING
)
{
...
...
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