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 |
Christopher Faulet | e50aabe | 2022-04-26 11:20:10 +0200 | [diff] [blame] | 7 | txresp -hdr "Connection: close" |
Tim Duesterhus | 4381d26 | 2019-10-16 15:11:15 +0200 | [diff] [blame] | 8 | } -repeat 3 -start |
| 9 | |
| 10 | haproxy h1 -conf { |
| 11 | defaults |
| 12 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 13 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 14 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 15 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Tim Duesterhus | 4381d26 | 2019-10-16 15:11:15 +0200 | [diff] [blame] | 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 |