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