Amaury Denoyelle | d86ae4b | 2021-01-26 14:35:23 +0100 | [diff] [blame] | 1 | varnishtest "Test the http-reuse safe mode" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.2 |
| 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | haproxy h1 -conf { |
| 8 | defaults |
| 9 | mode http |
| 10 | |
| 11 | # limit idle pool to one connection |
| 12 | # this forces connection reuse for the transaction after the first one |
| 13 | listen sender |
| 14 | bind "fd@${feS}" |
| 15 | http-reuse safe |
| 16 | http-request set-header client-id %[req.hdr(client-id)] if { req.hdr(client-id) -m found } |
| 17 | server srv ${h1_feR_addr}:${h1_feR_port} pool-max-conn 1 |
| 18 | |
| 19 | listen receiver |
| 20 | bind "fd@${feR}" |
| 21 | http-request set-var(sess.client_id) req.hdr(client-id) |
| 22 | http-request return status 200 |
| 23 | http-after-response set-header http_first_request %[http_first_req] |
| 24 | http-after-response set-header client-id %[var(sess.client_id)] |
| 25 | } -start |
| 26 | |
| 27 | client c1 -connect ${h1_feS_sock} { |
| 28 | txreq \ |
| 29 | -hdr "client-id: c1" |
| 30 | rxresp |
| 31 | expect resp.http.http_first_request == "1" |
| 32 | |
| 33 | txreq |
| 34 | rxresp |
| 35 | expect resp.http.http_first_request == "0" |
| 36 | expect resp.http.client-id == "c1" |
| 37 | |
| 38 | txreq |
| 39 | rxresp |
| 40 | expect resp.http.http_first_request == "0" |
| 41 | expect resp.http.client-id == "c1" |
| 42 | } -run |
| 43 | |
| 44 | client c2 -connect ${h1_feS_sock} { |
| 45 | txreq \ |
| 46 | -hdr "client-id: c2" |
| 47 | rxresp |
| 48 | expect resp.http.http_first_request == "1" |
| 49 | expect resp.http.client-id == "c2" |
| 50 | |
| 51 | txreq |
| 52 | rxresp |
| 53 | expect resp.http.http_first_request == "0" |
| 54 | expect resp.http.client-id == "c1" |
| 55 | |
| 56 | txreq |
| 57 | rxresp |
| 58 | expect resp.http.http_first_request == "0" |
| 59 | expect resp.http.client-id == "c1" |
| 60 | } -run |
| 61 | |
| 62 | client c3 -connect ${h1_feS_sock} { |
| 63 | txreq \ |
| 64 | -hdr "client-id: c3" |
| 65 | rxresp |
| 66 | expect resp.http.http_first_request == "1" |
| 67 | expect resp.http.client-id == "c3" |
| 68 | |
| 69 | txreq |
| 70 | rxresp |
| 71 | expect resp.http.http_first_request == "0" |
| 72 | expect resp.http.client-id == "c1" |
| 73 | |
| 74 | txreq |
| 75 | rxresp |
| 76 | expect resp.http.http_first_request == "0" |
| 77 | expect resp.http.client-id == "c1" |
| 78 | } -run |