blob: 31e85be668426d16ea5fa0b81cda916fc1293a7e [file] [log] [blame]
Christopher Faulet1c220482020-09-03 11:53:50 +02001varnishtest "path vs pathq tests"
2#REQUIRE_VERSION=2.2
3
4# This config tests various http request rules (set/replace) manipulating the
5# path, with or without the query-string. It also test path and pathq sample
6# fetches.
7
8feature ignore_unknown_macro
9
10server s1 {
11 rxreq
12 expect req.url == /regtest/foo/fe/req1/bar?param1=val1&param2=val2
13 expect req.http.x-path == /req1
14 expect req.http.x-pathq == /req1?param1=val1&param2=val2
15 expect req.http.x-query == param1=val1&param2=val2
16 expect req.http.x-url == /req1?param1=val1&param2=val2
17 txresp
18
19 rxreq
20 expect req.url == http://127.0.0.1/regtest/foo/fe/req2/bar?param1=val1&param2=val2
21 expect req.http.x-path == /req2
22 expect req.http.x-pathq == /req2?param1=val1&param2=val2
23 expect req.http.x-query == param1=val1&param2=val2
24 expect req.http.x-url == http://127.0.0.1/req2?param1=val1&param2=val2
25 txresp
26} -start
27
28haproxy h1 -conf {
29 defaults
30 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010031 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
32 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
33 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Christopher Faulet1c220482020-09-03 11:53:50 +020034
35 frontend fe
36 bind "fd@${fe}"
37
38 http-request add-header x-path %[path]
39 http-request add-header x-pathq %[pathq]
40 http-request add-header x-query %[query]
41 http-request add-header x-url %[url]
42
43 http-request set-path /fe%[path]
44 http-request replace-path (.*) /foo\1
45 http-request replace-path (.*) \1/bar
46 http-request set-pathq %[path]?app=regtest&%[query]
47 http-request replace-pathq /([^?]*)\?app=([^&]*)&?(.*) /\2/\1?\3
48
49 default_backend be
50
51 backend be
52 server s1 ${s1_addr}:${s1_port}
53
54} -start
55
56client c1 -connect ${h1_fe_sock} {
57 txreq -req GET -url /req1?param1=val1&param2=val2
58 rxresp
59 expect resp.status == 200
60
61 txreq -req GET -url http://127.0.0.1/req2?param1=val1&param2=val2
62 rxresp
63 expect resp.status == 200
64} -run