Amaury Denoyelle | a47dfab | 2021-03-02 14:39:20 +0100 | [diff] [blame] | 1 | varnishtest "Test the proper interaction between http-reuse and backend in transparent mode" |
| 2 | |
| 3 | # If backend is used with the transparent mode, the connection are considered |
| 4 | # as private and should only be reused for requests of the same session. |
| 5 | # This is similar to the http-reuse never mode |
| 6 | |
| 7 | #REQUIRE_VERSION=2.4 |
| 8 | |
| 9 | feature ignore_unknown_macro |
| 10 | |
| 11 | haproxy h1 -conf { |
| 12 | defaults |
| 13 | mode http |
| 14 | |
| 15 | listen sender |
| 16 | bind "fd@${feS}" |
| 17 | http-request set-header client-id %[req.hdr(client-id)] if { req.hdr(client-id) -m found } |
| 18 | option transparent |
| 19 | http-request set-dst-port int(${h1_feR_port}) |
| 20 | |
| 21 | listen receiver |
| 22 | bind "fd@${feR}" |
| 23 | http-request set-var(sess.client_id) req.hdr(client-id) |
| 24 | http-request return status 200 |
| 25 | http-after-response set-header http_first_request %[http_first_req] |
| 26 | http-after-response set-header client-id %[var(sess.client_id)] |
| 27 | } -start |
| 28 | |
| 29 | client c1 -connect ${h1_feS_sock} { |
| 30 | txreq \ |
| 31 | -hdr "client-id: c1" |
| 32 | rxresp |
| 33 | expect resp.http.http_first_request == "1" |
| 34 | |
| 35 | txreq |
| 36 | rxresp |
| 37 | expect resp.http.http_first_request == "0" |
| 38 | expect resp.http.client-id == "c1" |
| 39 | |
| 40 | txreq |
| 41 | rxresp |
| 42 | expect resp.http.http_first_request == "0" |
| 43 | expect resp.http.client-id == "c1" |
| 44 | } -run |
| 45 | |
| 46 | client c2 -connect ${h1_feS_sock} { |
| 47 | txreq \ |
| 48 | -hdr "client-id: c2" |
| 49 | rxresp |
| 50 | expect resp.http.http_first_request == "1" |
| 51 | expect resp.http.client-id == "c2" |
| 52 | |
| 53 | txreq |
| 54 | rxresp |
| 55 | expect resp.http.http_first_request == "0" |
| 56 | expect resp.http.client-id == "c2" |
| 57 | |
| 58 | txreq |
| 59 | rxresp |
| 60 | expect resp.http.http_first_request == "0" |
| 61 | expect resp.http.client-id == "c2" |
| 62 | } -run |
| 63 | |
| 64 | client c3 -connect ${h1_feS_sock} { |
| 65 | txreq \ |
| 66 | -hdr "client-id: c3" |
| 67 | rxresp |
| 68 | expect resp.http.http_first_request == "1" |
| 69 | expect resp.http.client-id == "c3" |
| 70 | |
| 71 | txreq |
| 72 | rxresp |
| 73 | expect resp.http.http_first_request == "0" |
| 74 | expect resp.http.client-id == "c3" |
| 75 | |
| 76 | txreq |
| 77 | rxresp |
| 78 | expect resp.http.http_first_request == "0" |
| 79 | expect resp.http.client-id == "c3" |
| 80 | } -run |
| 81 | |