Christopher Faulet | 475fab3 | 2021-02-10 10:20:26 +0100 | [diff] [blame] | 1 | varnishtest "A test to be sure payload is skipped for bodyless responses" |
| 2 | feature ignore_unknown_macro |
| 3 | |
| 4 | #REQUIRE_VERSION=2.4 |
| 5 | |
| 6 | server s1 { |
| 7 | rxreq |
| 8 | txresp \ |
| 9 | -status 200 \ |
| 10 | -body "skipped data" |
| 11 | |
| 12 | rxreq |
| 13 | txresp \ |
| 14 | -status 200 \ |
| 15 | -bodylen 20000 |
| 16 | |
| 17 | rxreq |
| 18 | txresp \ |
| 19 | -status 200 \ |
| 20 | -nolen -hdr "Transfer-Encoding: chunked" |
| 21 | chunkedlen 15 |
| 22 | chunkedlen 1024 |
| 23 | chunkedlen 4048 |
| 24 | chunkedlen 0 |
| 25 | |
| 26 | rxreq |
| 27 | txresp \ |
| 28 | -status 200 \ |
| 29 | -body "last response" |
| 30 | } -repeat 2 -start |
| 31 | |
| 32 | haproxy h1 -conf { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame] | 33 | global |
| 34 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 35 | # idle server connections being randomly used and randomly expiring |
| 36 | # under us. |
| 37 | tune.idle-pool.shared off |
| 38 | |
Christopher Faulet | 475fab3 | 2021-02-10 10:20:26 +0100 | [diff] [blame] | 39 | defaults |
| 40 | mode http |
Christopher Faulet | 475fab3 | 2021-02-10 10:20:26 +0100 | [diff] [blame] | 41 | timeout connect 1s |
| 42 | timeout client 1s |
| 43 | timeout server 1s |
| 44 | |
| 45 | listen fe1 |
| 46 | bind "fd@${fe1}" |
| 47 | # Rewrite the method to be sure to get the response payload |
| 48 | # on the server side |
| 49 | http-request set-method GET |
| 50 | server s1 ${s1_addr}:${s1_port} |
| 51 | |
| 52 | listen int |
| 53 | bind "fd@${int}" proto h2 |
| 54 | # Rewrite the method to be sure to get the response payload |
| 55 | # on the server side |
| 56 | http-request set-method GET |
| 57 | server s1 ${s1_addr}:${s1_port} |
| 58 | #server s1 ${h1_fe1_addr}:${h1_fe1_port} |
| 59 | |
| 60 | listen fe2 |
| 61 | bind "fd@${fe2}" |
| 62 | server s1 ${h1_int_addr}:${h1_int_port} proto h2 |
| 63 | } -start |
| 64 | |
| 65 | client c1 -connect ${h1_fe1_sock} { |
| 66 | txreq \ |
| 67 | -req "HEAD" \ |
| 68 | -url "/req1" |
| 69 | rxresp |
| 70 | expect resp.status == 200 |
| 71 | expect resp.body == "" |
| 72 | |
| 73 | txreq \ |
| 74 | -req "HEAD" \ |
| 75 | -url "/req2" |
| 76 | rxresp |
| 77 | expect resp.status == 200 |
| 78 | expect resp.body == "" |
| 79 | |
| 80 | txreq \ |
| 81 | -req "HEAD" \ |
| 82 | -url "/req3" |
| 83 | rxresp |
| 84 | expect resp.status == 200 |
| 85 | expect resp.body == "" |
| 86 | |
| 87 | # The last one have a body and validate the connection was not closed |
| 88 | # unexpectedly and no payload was received for previous requests |
| 89 | txreq \ |
| 90 | -req "GET" \ |
| 91 | -url "/req4" |
| 92 | rxresp |
| 93 | expect resp.status == 200 |
| 94 | expect resp.body == "last response" |
| 95 | } -run |
| 96 | |
| 97 | client c2 -connect ${h1_fe2_sock} { |
| 98 | txreq \ |
| 99 | -req "HEAD" \ |
| 100 | -url "/req1" |
| 101 | rxresp |
| 102 | expect resp.status == 200 |
| 103 | expect resp.body == "" |
| 104 | |
| 105 | txreq \ |
| 106 | -req "HEAD" \ |
| 107 | -url "/req2" |
| 108 | rxresp |
| 109 | expect resp.status == 200 |
| 110 | expect resp.body == "" |
| 111 | |
| 112 | txreq \ |
| 113 | -req "HEAD" \ |
| 114 | -url "/req3" |
| 115 | rxresp |
| 116 | expect resp.status == 200 |
| 117 | expect resp.body == "" |
| 118 | |
| 119 | # The last one have a body and validate the connection was not closed |
| 120 | # unexpectedly and no payload was received for previous requests |
| 121 | txreq \ |
| 122 | -req "GET" \ |
| 123 | -url "/req4" |
| 124 | rxresp |
| 125 | expect resp.status == 200 |
| 126 | expect resp.body == "last response" |
| 127 | } -run |