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 | |
| 13 | #REQUIRE_VERSION=1.6 |
| 14 | syslog S1 -level notice { |
| 15 | recv |
| 16 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy (fe|be)1 started." |
| 17 | recv |
| 18 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy (fe|be)1 started." |
| 19 | recv info |
| 20 | # not expecting ${h1_pid} with master-worker |
| 21 | expect ~ "[^:\\[ ]\\[[[:digit:]]+\\]: .* fe1 be1/s1 [[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+/[[:digit:]]+ 200 [[:digit:]]+ - - ---- .* \"GET / HTTP/(1|2)(\\.1)?\"" |
| 22 | } -start |
| 23 | |
| 24 | server s1 { |
| 25 | rxreq |
| 26 | expect req.method == "GET" |
| 27 | expect req.http.x-mapped-from-header == example_AND_org |
| 28 | expect req.http.x-mapped-from-var == example_AND_org |
| 29 | txresp |
| 30 | |
| 31 | rxreq |
| 32 | expect req.method == "GET" |
| 33 | expect req.http.x-mapped-from-header == www.example_AND_org |
| 34 | expect req.http.x-mapped-from-var == www.example_AND_org |
| 35 | txresp |
| 36 | } -start |
| 37 | |
| 38 | haproxy h1 -conf { |
| 39 | global |
| 40 | log ${S1_addr}:${S1_port} local0 debug err |
| 41 | |
| 42 | defaults |
| 43 | mode http |
| 44 | ${no-htx} option http-use-htx |
| 45 | log global |
| 46 | option httplog |
| 47 | timeout connect 15ms |
| 48 | timeout client 20ms |
| 49 | timeout server 20ms |
| 50 | |
| 51 | frontend fe1 |
| 52 | bind "fd@${fe1}" |
| 53 | # Remove port from Host header |
| 54 | http-request replace-value Host '(.*):.*' '\1' |
| 55 | # Store host header in variable |
| 56 | http-request set-var(txn.host) req.hdr(Host) |
| 57 | # This works correctly |
| 58 | http-request set-header X-Mapped-From-Header %[req.hdr(Host),map_regm(${testdir}/b00000.map,"unknown")] |
| 59 | # This breaks before commit 271022150d7961b9aa39dbfd88e0c6a4bc48c3ee |
| 60 | http-request set-header X-Mapped-From-Var %[var(txn.host),map_regm(${testdir}/b00000.map,"unknown")] |
| 61 | |
| 62 | default_backend be1 |
| 63 | |
| 64 | backend be1 |
| 65 | server s1 ${s1_addr}:${s1_port} |
| 66 | } -start |
| 67 | |
| 68 | client c1 -connect ${h1_fe1_sock} { |
| 69 | txreq -hdr "Host: example.org:8443" |
| 70 | rxresp |
| 71 | expect resp.status == 200 |
| 72 | |
| 73 | txreq -hdr "Host: www.example.org" |
| 74 | rxresp |
| 75 | expect resp.status == 200 |
| 76 | } -run |
| 77 | |