blob: 1f37c9f1f7309ab02d4331f1a0d4c36618f5430a [file] [log] [blame]
William Dauchy5417e892021-01-08 21:57:41 +01001varnishtest "json converter test"
2
William Dauchy5417e892021-01-08 21:57:41 +01003
4feature ignore_unknown_macro
5
6server s1 {
7 rxreq
8 txresp
9} -repeat 2 -start
10
11haproxy h1 -conf {
12 defaults
13 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010014 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
15 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
16 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
William Dauchy5417e892021-01-08 21:57:41 +010017
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
33client 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