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
cd445494
Commit
cd445494
authored
Aug 19, 2017
by
Federico G. Schwindt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose the hash via {bereq,req}.hash
This is available after vcl_hash{}. Tests will follow.
parent
94490066
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
4 deletions
+55
-4
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+37
-0
v00016.vtc
bin/varnishtest/tests/v00016.vtc
+2
-2
v00018.vtc
bin/varnishtest/tests/v00018.vtc
+2
-2
generate.py
lib/libvcc/generate.py
+14
-0
No files found.
bin/varnishd/cache/cache_vrt_var.c
View file @
cd445494
...
...
@@ -30,12 +30,15 @@
*/
#include "config.h"
#include <stdio.h>
#include "cache.h"
#include "common/heritage.h"
#include "cache_director.h"
#include "vrt.h"
#include "vrt_obj.h"
#include "vsha256.h"
static
char
vrt_hostname
[
255
]
=
""
;
...
...
@@ -761,6 +764,40 @@ VRT_BODY_L(resp)
/*--------------------------------------------------------------------*/
const
char
*
VRT_r_req_hash
(
VRT_CTX
)
{
char
*
p
;
int
i
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
p
=
WS_Alloc
(
ctx
->
ws
,
SHA256_LEN
*
2
+
1
);
if
(
p
==
NULL
)
return
(
NULL
);
for
(
i
=
0
;
i
<
SHA256_LEN
;
i
++
)
sprintf
(
&
p
[
i
*
2
],
"%02x"
,
ctx
->
req
->
digest
[
i
]);
return
(
p
);
}
const
char
*
VRT_r_bereq_hash
(
VRT_CTX
)
{
char
*
p
;
int
i
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
p
=
WS_Alloc
(
ctx
->
ws
,
SHA256_LEN
*
2
+
1
);
if
(
p
==
NULL
)
return
(
NULL
);
for
(
i
=
0
;
i
<
SHA256_LEN
;
i
++
)
sprintf
(
&
p
[
i
*
2
],
"%02x"
,
ctx
->
bo
->
digest
[
i
]);
return
(
p
);
}
/*--------------------------------------------------------------------*/
#define HTTP_VAR(x) \
struct http * \
VRT_r_##x(VRT_CTX) \
...
...
bin/varnishtest/tests/v00016.vtc
View file @
cd445494
...
...
@@ -41,9 +41,9 @@ varnish v1 -errvcl {Operator > not possible on BACKEND} {
sub vcl_recv { if (a > b) { } }
}
varnish v1 -errvcl {Symbol not found: 'req.
hash
' (expected type BOOL):} {
varnish v1 -errvcl {Symbol not found: 'req.
foo
' (expected type BOOL):} {
backend b { .host = "127.0.0.1"; }
sub vcl_hash { if (req.
hash != "foo
") { } }
sub vcl_hash { if (req.
foo != "bar
") { } }
}
varnish v1 -errvcl {Symbol not found: 'foo.bar'} {
...
...
bin/varnishtest/tests/v00018.vtc
View file @
cd445494
...
...
@@ -38,9 +38,9 @@ varnish v1 -errvcl {Expected ';' got 'if'} {
sub vcl_recv { set req.url = "foo" if "bar"; }
}
varnish v1 -errvcl {Symbol not found: 'req.
hash
' (expected type STRING_LIST):} {
varnish v1 -errvcl {Symbol not found: 'req.
foo
' (expected type STRING_LIST):} {
backend b { .host = "127.0.0.1"; }
sub vcl_hash { hash_data(req.
hash
); }
sub vcl_hash { hash_data(req.
foo
); }
}
varnish v1 -vcl {
...
...
lib/libvcc/generate.py
View file @
cd445494
...
...
@@ -233,6 +233,13 @@ sp_variables = [
The request type (e.g. "GET", "HEAD").
"""
),
(
'req.hash'
,
'STRING'
,
(
'hit'
,
'miss'
,
'pass'
,
'purge'
,
'deliver'
,
),
(),
"""
The hash key of this request.
"""
),
(
'req.url'
,
'STRING'
,
(
'client'
,),
...
...
@@ -418,6 +425,13 @@ sp_variables = [
The request body.
"""
),
(
'bereq.hash'
,
'STRING'
,
(
'pipe'
,
'backend'
,
),
(),
"""
The hash key of this request.
"""
),
(
'bereq.method'
,
'STRING'
,
(
'pipe'
,
'backend'
,
),
...
...
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