William Dauchy | 5417e89 | 2021-01-08 21:57:41 +0100 | [diff] [blame] | 1 | varnishtest "json converter test" |
| 2 | |
William Dauchy | 5417e89 | 2021-01-08 21:57:41 +0100 | [diff] [blame] | 3 | |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | server s1 { |
| 7 | rxreq |
| 8 | txresp |
| 9 | } -repeat 2 -start |
| 10 | |
| 11 | haproxy h1 -conf { |
| 12 | defaults |
| 13 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 14 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 15 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 16 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
William Dauchy | 5417e89 | 2021-01-08 21:57:41 +0100 | [diff] [blame] | 17 | |
| 18 | frontend fe |
| 19 | bind "fd@${fe}" |
| 20 | |
| 21 | http-response set-header json0 "%[str(foo 1/2),json]" |
| 22 | # bad UTF-8 sequence |
| 23 | http-response set-header json1 "%[str(\xE0),json(utf8)]" |
| 24 | # bad UTF-8 sequence, but removes them |
| 25 | http-response set-header json2 "%[str(-\xE0-),json(utf8s)]" |
| 26 | |
| 27 | default_backend be |
| 28 | |
| 29 | backend be |
| 30 | server s1 ${s1_addr}:${s1_port} |
| 31 | } -start |
| 32 | |
| 33 | client c1 -connect ${h1_fe_sock} { |
| 34 | txreq -url "/" |
| 35 | rxresp |
| 36 | expect resp.http.json0 == "foo 1\\/2" |
| 37 | expect resp.http.json1 == "" |
| 38 | expect resp.http.json2 == "--" |
| 39 | expect resp.status == 200 |
| 40 | } -run |