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