-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrewriting.vtc
69 lines (55 loc) · 1.55 KB
/
rewriting.vtc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
varnishtest "Testing URL rewriting for SPARQL Protocol"
server s1 {
rxreq
txresp
expect req.url == "/sparql?query=test"
expect req.method == "GET"
expect req.http.accept == "application/sparql-results+xml"
rxreq
txresp
expect req.url == "/sparql"
expect req.method == "POST"
expect req.body == "query=test"
expect req.http.accept == "application/sparql-results+xml"
rxreq
txresp
expect req.url == "/sparql"
expect req.method == "POST"
expect req.body == "update=test"
} -start
varnish v1 -vcl+backend {
vcl 4.0;
import std;
import bodyaccess;
sub vcl_recv {
if (req.method == "GET" && ! req.http.accept) {
set req.http.accept = "application/sparql-results+xml";
} else if (req.method == "POST") {
std.cache_req_body(500KB);
set req.http.X-Body-Len = bodyaccess.len_req_body();
if (req.http.X-Body-Len == "-1") {
return(synth(400, "The request body size exceeds the limit"));
}
if (bodyaccess.rematch_req_body("query=") == 1 && ! req.http.accept ) {
set req.http.accept = "application/sparql-results+xml";
}
# else if (bodyaccess.rematch_req_body("update=") == 1) {
#NOTHING
#}
return (pass);
}
#std.log(req.url)
}
} -start
client c1 {
#GET http://example.org/XXXX/sparql?query=
txreq -req "GET" -url "/sparql?query=test"
rxresp
#POST http://example.org/XXXX/sparql?query=
txreq -req "POST" -url "/sparql" -body "query=test"
rxresp
#POST http://example.org/XXXX/sparql?update=
txreq -req "POST" -url "/sparql" -body "update=test"
rxresp
} -run
# varnishtest rewriting.vtc