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
2c224f72
Commit
2c224f72
authored
Aug 02, 2013
by
Joshua Bussdieker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameter range modifier support.
parent
12b3a911
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
293 additions
and
6 deletions
+293
-6
cache_key.c
bin/varnishd/cache/cache_key.c
+73
-6
x00025.vtc
bin/varnishtest/tests/x00025.vtc
+22
-0
x00026.vtc
bin/varnishtest/tests/x00026.vtc
+22
-0
x00027.vtc
bin/varnishtest/tests/x00027.vtc
+22
-0
x00028.vtc
bin/varnishtest/tests/x00028.vtc
+22
-0
x00029.vtc
bin/varnishtest/tests/x00029.vtc
+22
-0
x00030.vtc
bin/varnishtest/tests/x00030.vtc
+22
-0
x00031.vtc
bin/varnishtest/tests/x00031.vtc
+22
-0
x00032.vtc
bin/varnishtest/tests/x00032.vtc
+22
-0
x00033.vtc
bin/varnishtest/tests/x00033.vtc
+22
-0
x00034.vtc
bin/varnishtest/tests/x00034.vtc
+22
-0
No files found.
bin/varnishd/cache/cache_key.c
View file @
2c224f72
...
...
@@ -15,6 +15,7 @@
#define M_CASE 4
#define M_NOT 5
#define M_PARAMETER 6
#define M_PARAMETER_RANGE 7
int
enum_matchers
(
const
char
*
matcher
,
int
*
type
,
const
char
**
param
,
int
*
s
)
{
const
char
*
p
=
matcher
;
...
...
@@ -65,6 +66,20 @@ int enum_matchers(const char *matcher, int *type, const char **param, int *s) {
*
s
=
(
int
)(
e
-
p
);
*
type
=
M_PARAMETER
;
p
=
e
+
1
;
}
else
if
(
strncmp
(
p
,
"pr="
,
3
)
==
0
)
{
p
+=
3
;
for
(
e
=
p
;
*
e
&&
*
e
!=
'['
&&
*
e
!=
';'
;
e
++
)
continue
;
if
(
*
e
!=
'['
)
return
-
1
;
for
(
e
=
p
;
*
e
&&
*
e
!=
']'
&&
*
e
!=
';'
;
e
++
)
continue
;
if
(
*
e
!=
']'
)
return
-
1
;
*
param
=
p
;
*
s
=
(
int
)(
e
-
p
)
+
1
;
*
type
=
M_PARAMETER_RANGE
;
p
=
e
+
1
;
}
else
if
(
*
p
==
'c'
)
{
*
s
=
0
;
*
type
=
M_CASE
;
...
...
@@ -219,6 +234,51 @@ int parameter_prefix_matcher(const char *p, const char *fv, int ps, int case_sen
return
0
;
}
int
parameter_range_matcher
(
const
char
*
p
,
const
char
*
fv
,
int
ps
,
int
case_sensitive
)
{
case_sensitive
=
0
;
// Always case insensitive
int
read
,
size
,
offset
=
0
;
const
char
*
match
;
int
min
=
99
,
max
=
0
;
int
has_min
=
1
,
has_max
=
1
;
char
*
x
=
p
;
for
(
x
=
p
;
*
x
&&
*
x
!=
'['
;
x
++
)
continue
;
char
*
prefix
=
x
-
1
;
ps
=
(
int
)(
prefix
-
p
)
+
1
;
if
(
strncmp
(
x
,
"[:"
,
2
))
{
if
(
!
sscanf
(
x
,
"[%d:"
,
&
min
))
{
return
0
;
}
else
has_min
=
0
;
}
for
(;
*
x
&&
*
x
!=
':'
;
x
++
)
continue
;
if
(
strncmp
(
x
,
":]"
,
2
))
{
if
(
!
sscanf
(
x
,
":%d]"
,
&
max
))
{
return
0
;
}
else
has_max
=
0
;
}
while
(
read
=
enum_fields
(
fv
+
offset
,
&
match
,
&
size
))
{
if
(
ps
<=
size
)
{
if
(
cmp_func
(
match
,
p
,
ps
,
case_sensitive
)
==
0
)
{
if
(
match
[
ps
]
==
'='
)
{
int
value
;
if
(
sscanf
(
match
+
ps
+
1
,
"%d"
,
&
value
))
{
if
((
has_min
||
(
value
>=
min
))
&&
(
has_max
||
(
value
<=
max
)))
return
1
;
}
}
}
}
offset
+=
read
;
}
return
0
;
}
int
unescape
(
char
*
dst
,
const
char
*
src
,
int
len
)
{
int
i
,
j
;
i
=
j
=
0
;
...
...
@@ -494,6 +554,13 @@ KEY_Match(struct http *http, const uint8_t *key)
if
(
!
(
subresult
^
not_flag
))
result
=
0
;
break
;
case
M_PARAMETER_RANGE
:
while
(
u
=
http_EnumHdr
(
http
,
u
,
(
const
char
*
)(
key
+
3
),
&
h
))
{
subresult
|=
parameter_range_matcher
(
m
,
h
,
strlen
(
m
),
case_flag
);
}
if
(
!
(
subresult
^
not_flag
))
result
=
0
;
break
;
case
M_CASE
:
case_flag
=
1
;
break
;
...
...
bin/varnishtest/tests/x00025.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: BAr=25"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: BAr=25"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
bin/varnishtest/tests/x00026.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: bar=30, baz=100"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: bar=30, baz=100"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
bin/varnishtest/tests/x00027.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: baz=10, bar=50, bar=10, bar=21"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: baz=10, bar=50, bar=10, bar=21"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
bin/varnishtest/tests/x00028.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: bar=19"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: bar=19"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
} -run
bin/varnishtest/tests/x00029.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: bar="
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: bar="
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
} -run
bin/varnishtest/tests/x00030.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: bar=-30"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: bar=-30"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
} -run
bin/varnishtest/tests/x00031.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: thing=100"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: thing=100"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
} -run
bin/varnishtest/tests/x00032.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
rxreq
txresp -hdr "Key: Foobar;pr=bar[20:30]"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: bar"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: bar"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
} -run
bin/varnishtest/tests/x00033.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
bin/varnishtest/tests/x00034.vtc
0 → 100644
View file @
2c224f72
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -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