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
c2cb5e71
Commit
c2cb5e71
authored
May 16, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add read-only access to the top level request in an ESI tree.
Patch from daghf (with minor changes)
parent
eb8f35bd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
1 deletion
+122
-1
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+1
-0
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+3
-0
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+4
-0
e00030.vtc
bin/varnishtest/tests/e00030.vtc
+76
-0
vrt.h
include/vrt.h
+3
-1
generate.py
lib/libvcc/generate.py
+35
-0
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
c2cb5e71
...
...
@@ -475,6 +475,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
vsl
=
req
->
vsl
;
ctx
.
vcl
=
req
->
vcl
;
ctx
.
http_req
=
req
->
http
;
ctx
.
http_req_top
=
req
->
top
->
http
;
ctx
.
http_resp
=
req
->
resp
;
ctx
.
req
=
req
;
ctx
.
now
=
req
->
t_prev
;
...
...
bin/varnishd/cache/cache_vrt.c
View file @
c2cb5e71
...
...
@@ -96,6 +96,9 @@ VRT_selecthttp(VRT_CTX, enum gethdr_e where)
case
HDR_REQ
:
hp
=
ctx
->
http_req
;
break
;
case
HDR_REQ_TOP
:
hp
=
ctx
->
http_req_top
;
break
;
case
HDR_BEREQ
:
hp
=
ctx
->
http_bereq
;
break
;
...
...
bin/varnishd/cache/cache_vrt_var.c
View file @
c2cb5e71
...
...
@@ -119,6 +119,10 @@ VRT_HDR_LR(req, method, HTTP_HDR_METHOD)
VRT_HDR_LR
(
req
,
url
,
HTTP_HDR_URL
)
VRT_HDR_LR
(
req
,
proto
,
HTTP_HDR_PROTO
)
VRT_HDR_R
(
req_top
,
method
,
HTTP_HDR_METHOD
)
VRT_HDR_R
(
req_top
,
url
,
HTTP_HDR_URL
)
VRT_HDR_R
(
req_top
,
proto
,
HTTP_HDR_PROTO
)
VRT_HDR_LR
(
resp
,
proto
,
HTTP_HDR_PROTO
)
VRT_HDR_LR
(
resp
,
reason
,
HTTP_HDR_REASON
)
VRT_STATUS_L
(
resp
)
...
...
bin/varnishtest/tests/e00030.vtc
0 → 100644
View file @
c2cb5e71
varnishtest "Test req_top.* in an ESI context"
varnish v1 -errvcl {Variable 'req_top.url' is read only.} {
sub vcl_recv {
set req_top.url = "/foo";
}
}
server s1 {
rxreq
expect req.http.top-url == "/"
expect req.http.top-method == "GET"
expect req.http.top-proto == "HTTP/1.1"
expect req.http.top-foo == "bar"
txresp -body {
<html>
Before include
<esi:include
src=
"/a"
/>
<esi:include
src=
"/b"
/>
After include
</html>
}
rxreq
expect req.url == "/a1"
expect req.http.top-url == "/"
expect req.http.top-method == "GET"
expect req.http.top-proto == "HTTP/1.1"
expect req.http.top-foo == "bar"
txresp -body {
Included file
<esi:include
src=
"/c"
/>
}
rxreq
expect req.http.top-url == "/"
expect req.http.top-method == "GET"
expect req.http.top-proto == "HTTP/1.1"
expect req.http.top-foo == "bar"
expect req.url == "/b1"
txresp
rxreq
expect req.http.top-url == "/"
expect req.http.top-method == "GET"
expect req.http.top-proto == "HTTP/1.1"
expect req.http.top-foo == "bar"
expect req.url == "/c2"
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.esi_level > 0) {
set req.url = req.url + req.esi_level;
} else {
set req.http.foo = "bar";
}
set req.http.top-url = req_top.url;
set req.http.top-method = req_top.method;
set req.http.top-proto = req_top.proto;
set req.http.top-foo = req_top.http.foo;
}
sub vcl_backend_response {
set beresp.do_esi = true;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
varnish v1 -expect esi_errors == 0
include/vrt.h
View file @
c2cb5e71
...
...
@@ -100,6 +100,7 @@ struct vrt_ctx {
struct
req
*
req
;
struct
http
*
http_req
;
struct
http
*
http_req_top
;
struct
http
*
http_resp
;
struct
busyobj
*
bo
;
...
...
@@ -136,7 +137,8 @@ struct vmod_data {
/***********************************************************************/
enum
gethdr_e
{
HDR_REQ
,
HDR_RESP
,
HDR_OBJ
,
HDR_BEREQ
,
HDR_BERESP
};
enum
gethdr_e
{
HDR_REQ
,
HDR_REQ_TOP
,
HDR_RESP
,
HDR_OBJ
,
HDR_BEREQ
,
HDR_BERESP
};
struct
gethdr_s
{
enum
gethdr_e
where
;
...
...
lib/libvcc/generate.py
View file @
c2cb5e71
...
...
@@ -317,6 +317,41 @@ sp_variables = [
always (re)fetch from the backend.
"""
),
(
'req_top.method'
,
'STRING'
,
(
'client'
,),
(),
"""
The request method of the top-level request in a tree
of ESI requests. (e.g. "GET", "HEAD").
Identical to req.method in non-ESI requests.
"""
),
(
'req_top.url'
,
'STRING'
,
(
'client'
,),
(),
"""
The requested URL of the top-level request in a tree
of ESI requests.
Identical to req.url in non-ESI requests.
"""
),
(
'req_top.http.'
,
'HEADER'
,
(
'client'
,),
(),
"""
HTTP headers of the top-level request in a tree of ESI requests.
Identical to req.http. in non-ESI requests.
"""
),
(
'req_top.proto'
,
'STRING'
,
(
'client'
,),
(),
"""
HTTP protocol version of the top-level request in a tree of
ESI requests.
Identical to req.proto in non-ESI requests.
"""
),
(
'bereq'
,
'HTTP'
,
(
'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