Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 1 | #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 | |
| 10 | varnishtest "map_regm get_trash_chunk test" |
| 11 | feature ignore_unknown_macro |
| 12 | |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 13 | #REGTEST_TYPE=bug |
| 14 | |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 15 | syslog S1 -level notice { |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 16 | recv info |
| 17 | # not expecting ${h1_pid} with master-worker |
| 18 | expect ~ "[^:\\[ ]\\[[[:digit:]]+\\]: .* fe1 be1/s1 [[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+ 200 [[:digit:]]+ - - ---- .* \"GET / HTTP/(1|2)(\\.1)?\"" |
| 19 | } -start |
| 20 | |
| 21 | server s1 { |
| 22 | rxreq |
| 23 | expect req.method == "GET" |
| 24 | expect req.http.x-mapped-from-header == example_AND_org |
| 25 | expect req.http.x-mapped-from-var == example_AND_org |
| 26 | txresp |
| 27 | |
| 28 | rxreq |
| 29 | expect req.method == "GET" |
| 30 | expect req.http.x-mapped-from-header == www.example_AND_org |
| 31 | expect req.http.x-mapped-from-var == www.example_AND_org |
| 32 | txresp |
| 33 | } -start |
| 34 | |
| 35 | haproxy h1 -conf { |
| 36 | global |
| 37 | log ${S1_addr}:${S1_port} local0 debug err |
| 38 | |
| 39 | defaults |
| 40 | mode http |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 41 | log global |
| 42 | option httplog |
Willy Tarreau | db522b5 | 2020-09-02 07:26:08 +0200 | [diff] [blame] | 43 | timeout connect 1s |
| 44 | timeout client 1s |
| 45 | timeout server 1s |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 46 | |
| 47 | frontend fe1 |
| 48 | bind "fd@${fe1}" |
| 49 | # Remove port from Host header |
| 50 | http-request replace-value Host '(.*):.*' '\1' |
| 51 | # Store host header in variable |
| 52 | http-request set-var(txn.host) req.hdr(Host) |
| 53 | # This works correctly |
Frédéric Lécaille | b894f92 | 2019-03-29 16:13:48 +0100 | [diff] [blame] | 54 | http-request set-header X-Mapped-From-Header %[req.hdr(Host),map_regm(${testdir}/map_regm_with_backref.map,"unknown")] |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 55 | # This breaks before commit 271022150d7961b9aa39dbfd88e0c6a4bc48c3ee |
Frédéric Lécaille | b894f92 | 2019-03-29 16:13:48 +0100 | [diff] [blame] | 56 | http-request set-header X-Mapped-From-Var %[var(txn.host),map_regm(${testdir}/map_regm_with_backref.map,"unknown")] |
Jarno Huuskonen | 3f0f578 | 2019-01-09 13:41:19 +0200 | [diff] [blame] | 57 | |
| 58 | default_backend be1 |
| 59 | |
| 60 | backend be1 |
| 61 | server s1 ${s1_addr}:${s1_port} |
| 62 | } -start |
| 63 | |
| 64 | client c1 -connect ${h1_fe1_sock} { |
| 65 | txreq -hdr "Host: example.org:8443" |
| 66 | rxresp |
| 67 | expect resp.status == 200 |
| 68 | |
| 69 | txreq -hdr "Host: www.example.org" |
| 70 | rxresp |
| 71 | expect resp.status == 200 |
| 72 | } -run |
| 73 | |