1
+ varnishtest "VMOD vfp & vdp - request bodies"
2
+
3
+ # this test mirrors m00048.vtc with directions reversed
4
+
5
+ server s1 {
6
+ rxreq
7
+ expect req.body == "Cbagb Snpgb, Pnrfne Genafvg!"
8
+ txresp
9
+ } -start
10
+
11
+ varnish v1 -vcl+backend {
12
+ import debug;
13
+
14
+ sub vcl_backend_fetch {
15
+ set bereq.filters = "rot13 debug.pedantic";
16
+ }
17
+ } -start
18
+
19
+ client c1 {
20
+ txreq -req POST -body "Ponto Facto, Caesar Transit!"
21
+ rxresp
22
+ expect resp.status == 200
23
+ } -run
24
+
25
+ varnish v1 -vsl_catchup
26
+
27
+ varnish v1 -vcl+backend {
28
+ import debug;
29
+
30
+ sub vcl_backend_fetch {
31
+ set bereq.filters = "rot13 rot13a";
32
+ }
33
+ }
34
+
35
+ client c1 {
36
+ txreq -req POST -body "Ponto Facto, Caesar Transit!"
37
+ rxresp
38
+ expect resp.status == 503
39
+ } -run
40
+
41
+
42
+ server s1 -wait
43
+
44
+ server s1 -repeat 4 {
45
+ rxreq
46
+ expect req.body == "Ponto Facto, Caesar Transit!"
47
+ txresp
48
+
49
+ rxreq
50
+ expect req.http.rot13 == "please"
51
+ expect req.body == "Cbagb Snpgb, Pnrfne Genafvg!"
52
+ txresp
53
+
54
+ rxreq
55
+ expect req.http.rot13 == "please"
56
+ expect req.http.back13 == "undoes"
57
+ expect req.body == "Ponto Facto, Caesar Transit!"
58
+ txresp
59
+ } -start
60
+
61
+ varnish v1 -vcl+backend {
62
+ import debug;
63
+ import std;
64
+
65
+ sub vcl_recv {
66
+ if (req.http.rot13) {
67
+ set req.filters = "rot13";
68
+ }
69
+ if (req.http.cache) {
70
+ std.cache_req_body(1MB);
71
+ if (req.http.wrong) {
72
+ set req.filters += " rot13";
73
+ }
74
+ }
75
+ }
76
+
77
+ sub vcl_backend_fetch {
78
+ if (bereq.http.back13) {
79
+ set bereq.filters = "rot13 debug.pedantic";
80
+ }
81
+ }
82
+ }
83
+
84
+ client c1 -repeat 2 {
85
+ txreq -req POST -body "Ponto Facto, Caesar Transit!"
86
+ rxresp
87
+ expect resp.status == 200
88
+
89
+ txreq -req POST -hdr "rot13: please" \
90
+ -body "Ponto Facto, Caesar Transit!"
91
+ rxresp
92
+ expect resp.status == 200
93
+
94
+ txreq -req POST -hdr "rot13: please" -hdr "back13: undoes" \
95
+ -body "Ponto Facto, Caesar Transit!"
96
+ rxresp
97
+ expect resp.status == 200
98
+
99
+ txreq -req POST -hdr "Cache: yes" \
100
+ -body "Ponto Facto, Caesar Transit!"
101
+ rxresp
102
+ expect resp.status == 200
103
+
104
+ txreq -req POST -hdr "Cache: yes" -hdr "rot13: please" \
105
+ -body "Ponto Facto, Caesar Transit!"
106
+ rxresp
107
+ expect resp.status == 200
108
+
109
+ txreq -req POST -hdr "Cache: yes" \
110
+ -hdr "rot13: please" -hdr "back13: undoes" \
111
+ -body "Ponto Facto, Caesar Transit!"
112
+ rxresp
113
+ expect resp.status == 200
114
+ } -run
115
+
116
+ logexpect l1 -v v1 -g raw {
117
+ expect * * VCL_Error "^req\\.filters not settable"
118
+ } -start
119
+
120
+ client c1 {
121
+ txreq -req POST -hdr "Cache: yes" -hdr "Wrong: it.is" \
122
+ -body "No second thoughts after caching"
123
+ rxresp
124
+ expect resp.status == 503
125
+ } -run
126
+
127
+ logexpect l1 -wait
0 commit comments