2018-12-19 10:49:39 +00:00
|
|
|
varnishtest "HTTP request tests: H1 to H1 (HTX mode supported only for HAProxy >= 1.9)"
|
2018-12-13 18:35:29 +00:00
|
|
|
#REQUIRE_VERSION=1.6
|
|
|
|
|
|
|
|
# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
|
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
server s1 {
|
2019-04-01 09:26:25 +00:00
|
|
|
##
|
|
|
|
## Handle GET requests
|
|
|
|
##
|
2018-12-13 18:35:29 +00:00
|
|
|
rxreq
|
2019-04-01 09:26:25 +00:00
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
2018-12-13 18:35:29 +00:00
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 1"
|
|
|
|
|
|
|
|
rxreq
|
2019-04-01 09:26:25 +00:00
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
2018-12-13 18:35:29 +00:00
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 2"
|
|
|
|
|
|
|
|
rxreq
|
2019-04-01 09:26:25 +00:00
|
|
|
expect req.bodylen == 38
|
|
|
|
expect req.body == "this must be delivered, like it or not"
|
2018-12-13 18:35:29 +00:00
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 3"
|
|
|
|
|
|
|
|
rxreq
|
2019-04-01 09:26:25 +00:00
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 4"
|
|
|
|
|
|
|
|
accept
|
|
|
|
|
|
|
|
##
|
|
|
|
## Handle HEAD requests
|
|
|
|
##
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 1"
|
|
|
|
|
|
|
|
accept
|
|
|
|
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 2"
|
|
|
|
|
|
|
|
accept
|
|
|
|
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 38
|
|
|
|
expect req.body == "this must be delivered, like it or not"
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 3"
|
|
|
|
|
|
|
|
accept
|
|
|
|
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 4"
|
|
|
|
|
|
|
|
accept
|
|
|
|
|
|
|
|
##
|
|
|
|
## Handle POST requests
|
|
|
|
##
|
|
|
|
# POST request without body
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 1"
|
|
|
|
|
|
|
|
# POST request without body
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 2"
|
|
|
|
|
|
|
|
# POST request with a body
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 12
|
|
|
|
expect req.body == "this is sent"
|
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 3"
|
|
|
|
|
|
|
|
# POST request without body
|
|
|
|
rxreq
|
|
|
|
expect req.bodylen == 0
|
|
|
|
expect req.body == ""
|
2018-12-13 18:35:29 +00:00
|
|
|
txresp \
|
|
|
|
-status 200 \
|
|
|
|
-body "response 4"
|
2019-03-26 10:06:29 +00:00
|
|
|
} -repeat 3 -start
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
defaults
|
|
|
|
mode http
|
2018-12-19 10:49:39 +00:00
|
|
|
${no-htx} option http-use-htx
|
2018-12-13 18:35:29 +00:00
|
|
|
timeout connect 1s
|
|
|
|
timeout client 1s
|
|
|
|
timeout server 1s
|
|
|
|
|
|
|
|
listen feh1
|
|
|
|
bind "fd@${feh1}"
|
|
|
|
#bind "fd@${feh2}" proto h2
|
|
|
|
server s1 ${s1_addr}:${s1_port}
|
|
|
|
} -start
|
|
|
|
|
|
|
|
# GET requests
|
|
|
|
client c1h1 -connect ${h1_feh1_sock} {
|
|
|
|
# first request is valid
|
|
|
|
txreq \
|
|
|
|
-req "GET" \
|
|
|
|
-url "/test1.html"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 1"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# second request is valid and advertises C-L:0
|
|
|
|
txreq \
|
|
|
|
-req "GET" \
|
|
|
|
-url "/test2.html" \
|
|
|
|
-hdr "content-length: 0"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 2"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# third request sends a body with a GET
|
|
|
|
txreq \
|
|
|
|
-req "GET" \
|
|
|
|
-url "/test3.html" \
|
|
|
|
-body "this must be delivered, like it or not"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 3"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# fourth request is valid and advertises C-L:0, and close, and is
|
|
|
|
# followed by a string "this is not sent\r\n\r\n" which must be
|
|
|
|
# dropped.
|
|
|
|
txreq \
|
|
|
|
-req "GET" \
|
|
|
|
-url "/test4.html" \
|
|
|
|
-hdr "content-length: 0" \
|
|
|
|
-hdr "connection: close"
|
|
|
|
# "this is not sent"
|
|
|
|
sendhex "74787973207973206E6F742073656E740D0A0D0A"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 4"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# the connection is expected to be closed and no more response must
|
|
|
|
# arrive here.
|
|
|
|
expect_close
|
|
|
|
} -run
|
|
|
|
|
|
|
|
# HEAD requests
|
|
|
|
# Note: for now they fail with varnishtest, which expects the amount of
|
|
|
|
# data advertised in the content-length response.
|
2019-03-26 10:06:29 +00:00
|
|
|
client c2h1 -connect ${h1_feh1_sock} {
|
|
|
|
# first request is valid
|
|
|
|
txreq \
|
|
|
|
-req "HEAD" \
|
|
|
|
-url "/test11.html"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == ""
|
2019-03-26 10:06:29 +00:00
|
|
|
|
|
|
|
# second request is valid and advertises C-L:0
|
|
|
|
txreq \
|
|
|
|
-req "HEAD" \
|
|
|
|
-url "/test12.html" \
|
|
|
|
-hdr "content-length: 0"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == ""
|
2019-03-26 10:06:29 +00:00
|
|
|
|
2019-04-01 09:26:25 +00:00
|
|
|
# third request sends a body with a HEAD
|
2019-03-26 10:06:29 +00:00
|
|
|
txreq \
|
2019-04-01 09:26:25 +00:00
|
|
|
-req "HEAD" \
|
2019-03-26 10:06:29 +00:00
|
|
|
-url "/test13.html" \
|
|
|
|
-body "this must be delivered, like it or not"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == ""
|
2019-03-26 10:06:29 +00:00
|
|
|
|
|
|
|
# fourth request is valid and advertises C-L:0, and close, and is
|
|
|
|
# followed by a string "this is not sent\r\n\r\n" which must be
|
|
|
|
# dropped.
|
|
|
|
txreq \
|
|
|
|
-req "HEAD" \
|
|
|
|
-url "/test14.html" \
|
|
|
|
-hdr "content-length: 0" \
|
|
|
|
-hdr "connection: close"
|
|
|
|
# "this is not sent"
|
|
|
|
sendhex "74787973207973206E6F742073656E740D0A0D0A"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == ""
|
2019-03-26 10:06:29 +00:00
|
|
|
|
|
|
|
# the connection is expected to be closed and no more response must
|
|
|
|
# arrive here.
|
|
|
|
expect_close
|
|
|
|
} -run
|
2018-12-13 18:35:29 +00:00
|
|
|
|
2019-04-01 09:26:25 +00:00
|
|
|
client c3h1 -connect ${h1_feh1_sock} {
|
2018-12-13 18:35:29 +00:00
|
|
|
# first request is valid
|
|
|
|
txreq \
|
|
|
|
-req "POST" \
|
|
|
|
-url "/test21.html"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 1"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# second request is valid and advertises C-L:0
|
|
|
|
txreq \
|
|
|
|
-req "POST" \
|
|
|
|
-url "/test22.html" \
|
|
|
|
-hdr "content-length: 0"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 2"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
2020-06-21 16:42:57 +00:00
|
|
|
# third request is valid and advertises (and sends) some contents
|
2018-12-13 18:35:29 +00:00
|
|
|
txreq \
|
|
|
|
-req "POST" \
|
|
|
|
-url "/test23.html" \
|
|
|
|
-body "this is sent"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 3"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# fourth request is valid and advertises C-L:0, and close, and is
|
|
|
|
# followed by a string "this is not sent\r\n\r\n" which must be
|
|
|
|
# dropped.
|
|
|
|
txreq \
|
|
|
|
-req "POST" \
|
|
|
|
-url "/test24.html" \
|
|
|
|
-hdr "content-length: 0" \
|
|
|
|
-hdr "connection: close"
|
|
|
|
# "this is not sent"
|
|
|
|
sendhex "74787973207973206E6F742073656E740D0A0D0A"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
2019-04-01 09:26:25 +00:00
|
|
|
expect resp.body == "response 4"
|
2018-12-13 18:35:29 +00:00
|
|
|
|
|
|
|
# the connection is expected to be closed and no more response must
|
|
|
|
# arrive here.
|
|
|
|
expect_close
|
|
|
|
} -run
|