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