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 | 085d62d | 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 { |
| 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 | |
| 26 | server 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 | |
| 40 | haproxy 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écaille | b894f92 | 2019-03-29 16:13:48 +0100 | [diff] [blame] | 60 | 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] | 61 | # This breaks before commit 271022150d7961b9aa39dbfd88e0c6a4bc48c3ee |
Frédéric Lécaille | b894f92 | 2019-03-29 16:13:48 +0100 | [diff] [blame] | 62 | 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] | 63 | |
| 64 | default_backend be1 |
| 65 | |
| 66 | backend be1 |
| 67 | server s1 ${s1_addr}:${s1_port} |
| 68 | } -start |
| 69 | |
| 70 | client 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 | |