blob: 502e8d376f8b6e4127aad62e583a994025f8b241 [file] [log] [blame]
Jarno Huuskonen3f0f5782019-01-09 13:41:19 +02001#commit 271022150d7961b9aa39dbfd88e0c6a4bc48c3ee
2# BUG/MINOR: map: fix map_regm with backref
3#
4# Due to a cascade of get_trash_chunk calls the sample is
5# corrupted when we want to read it.
6#
7# The fix consist to use a temporary chunk to copy the sample
8# value and use it.
9
10varnishtest "map_regm get_trash_chunk test"
11feature ignore_unknown_macro
12
13#REQUIRE_VERSION=1.6
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +010014#REGTEST_TYPE=bug
15
Jarno Huuskonen3f0f5782019-01-09 13:41:19 +020016syslog S1 -level notice {
17 recv
18 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy (fe|be)1 started."
19 recv
20 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy (fe|be)1 started."
21 recv info
22 # not expecting ${h1_pid} with master-worker
23 expect ~ "[^:\\[ ]\\[[[:digit:]]+\\]: .* fe1 be1/s1 [[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+ 200 [[:digit:]]+ - - ---- .* \"GET / HTTP/(1|2)(\\.1)?\""
24} -start
25
26server s1 {
27 rxreq
28 expect req.method == "GET"
29 expect req.http.x-mapped-from-header == example_AND_org
30 expect req.http.x-mapped-from-var == example_AND_org
31 txresp
32
33 rxreq
34 expect req.method == "GET"
35 expect req.http.x-mapped-from-header == www.example_AND_org
36 expect req.http.x-mapped-from-var == www.example_AND_org
37 txresp
38} -start
39
40haproxy h1 -conf {
41 global
42 log ${S1_addr}:${S1_port} local0 debug err
43
44 defaults
45 mode http
46 ${no-htx} option http-use-htx
47 log global
48 option httplog
49 timeout connect 15ms
50 timeout client 20ms
51 timeout server 20ms
52
53 frontend fe1
54 bind "fd@${fe1}"
55 # Remove port from Host header
56 http-request replace-value Host '(.*):.*' '\1'
57 # Store host header in variable
58 http-request set-var(txn.host) req.hdr(Host)
59 # This works correctly
Frédéric Lécailleb894f922019-03-29 16:13:48 +010060 http-request set-header X-Mapped-From-Header %[req.hdr(Host),map_regm(${testdir}/map_regm_with_backref.map,"unknown")]
Jarno Huuskonen3f0f5782019-01-09 13:41:19 +020061 # This breaks before commit 271022150d7961b9aa39dbfd88e0c6a4bc48c3ee
Frédéric Lécailleb894f922019-03-29 16:13:48 +010062 http-request set-header X-Mapped-From-Var %[var(txn.host),map_regm(${testdir}/map_regm_with_backref.map,"unknown")]
Jarno Huuskonen3f0f5782019-01-09 13:41:19 +020063
64 default_backend be1
65
66 backend be1
67 server s1 ${s1_addr}:${s1_port}
68} -start
69
70client c1 -connect ${h1_fe1_sock} {
71 txreq -hdr "Host: example.org:8443"
72 rxresp
73 expect resp.status == 200
74
75 txreq -hdr "Host: www.example.org"
76 rxresp
77 expect resp.status == 200
78} -run
79