Tim Duesterhus | 4381d26 | 2019-10-16 15:11:15 +0200 | [diff] [blame] | 1 | varnishtest "field converter Test" |
| 2 | |
| 3 | feature ignore_unknown_macro |
| 4 | |
| 5 | server s1 { |
| 6 | rxreq |
| 7 | txresp |
| 8 | } -repeat 3 -start |
| 9 | |
| 10 | haproxy h1 -conf { |
| 11 | defaults |
| 12 | mode http |
| 13 | timeout connect 1s |
| 14 | timeout client 1s |
| 15 | timeout server 1s |
| 16 | |
| 17 | frontend fe |
| 18 | bind "fd@${fe}" |
| 19 | |
| 20 | #### requests |
| 21 | http-request set-var(txn.uri) path |
| 22 | http-response set-header Found %[var(txn.uri),field(3,/)] if { var(txn.uri),field(3,/) -m found } |
| 23 | |
| 24 | default_backend be |
| 25 | |
| 26 | backend be |
| 27 | server s1 ${s1_addr}:${s1_port} |
| 28 | } -start |
| 29 | |
| 30 | client c1 -connect ${h1_fe_sock} { |
| 31 | txreq -url "/foo/bar/baz" |
| 32 | rxresp |
| 33 | expect resp.status == 200 |
| 34 | expect resp.http.found == "bar" |
| 35 | txreq -url "/foo" |
| 36 | rxresp |
| 37 | expect resp.status == 200 |
| 38 | expect resp.http.found == "<undef>" |
| 39 | } -run |