http-hardening adv-meth
reject-advanced-methods on
+ http-hardening req-pld
+ reject-unexpected-request-payload on
+
defaults
mode http
http-reuse never
bind "fd@${req_clte}" http-hardening clte
bind "fd@${req_cl0}" http-hardening cl0
bind "fd@${req_adv_meth}" http-hardening adv-meth
+ bind "fd@${req_pld}" http-hardening req-pld
http-request return status 200 hdr x-meth "%[method]" hdr x-hdrs "%[req.hdr_names]" hdr x-foo "%[req.hdr(foo),hex]"
# response side: one listener per server profile
expect resp.status == 200
expect resp.http.x-meth == "MY-METH"
+ txreq -nouseragent -req GET -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req POST -nolen -hdr "transfer-encoding: chunked" -body "2\r\nok\r\n0\r\n\r\n"
+ rxresp
+ expect resp.status == 200
+
# T-E + C-L forces a close
txreq -nouseragent -req POST -nolen -hdr "content-length: 2" -hdr "transfer-encoding: chunked" -body "2\r\nok\r\n0\r\n\r\n"
rxresp
expect_close
} -run
+# payloads are accepted on methods which define their semantics, and an
+# empty one is accepted everywhere. Chunking is always rejected.
+client c_req_pld -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req GET
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req GET -nolen -hdr "content-length: 0"
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req POST -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req PUT -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req PATCH -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req GET -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
+# the error response to HEAD carries a body that vtest doesn't read, so there
+# is no expect_close here.
+client c_req_pld2 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req HEAD -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 400
+} -run
+
+client c_req_pld3 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req DELETE -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
+client c_req_pld4 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req OPTIONS -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
+client c_req_pld5 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req TRACE -nolen -hdr "content-length: 2" -body "ok"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
+client c_req_pld6 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req POST -nolen -hdr "transfer-encoding: chunked" -body "2\r\nok\r\n0\r\n\r\n"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
+client c_req_pld7 -connect ${h1_req_pld_sock} {
+ txreq -nouseragent -req GET -nolen -hdr "transfer-encoding: chunked" -body "0\r\n\r\n"
+ rxresp
+ expect resp.status == 400
+ expect_close
+} -run
+
#
# Responses
#
http-hardening adv-meth
reject-advanced-methods on
+ http-hardening req-pld
+ reject-unexpected-request-payload on
+
defaults
mode http
http-reuse never
bind "fd@${req_ctl}" proto h2 http-hardening ctl
bind "fd@${req_cl0}" proto h2 http-hardening cl0
bind "fd@${req_adv_meth}" proto h2 http-hardening adv-meth
+ bind "fd@${req_pld}" proto h2 http-hardening req-pld
http-request return status 200 hdr x-meth "%[method]" hdr x-hdrs "%[req.hdr_names]" hdr x-foo "%[req.hdr(foo),hex]"
# response side: one listener per server
expect resp.status == 200
expect resp.http.x-meth == "MY-METH"
} -run
+ stream 17 {
+ txreq -req GET -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxresp
+ expect resp.status == 200
+ } -run
} -run
# without :authority, Host is the only source of the authority
} -run
} -run
+# payloads are only accepted on methods which define their semantics
+client c_req_pld -connect ${h1_req_pld_sock} {
+ txpri
+ stream 0 {
+ txsettings
+ rxsettings
+ txsettings -ack
+ rxsettings
+ expect settings.ack == true
+ } -run
+
+ stream 1 {
+ txreq -req GET -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ } -run
+ stream 3 {
+ txreq -req POST -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxresp
+ expect resp.status == 200
+ } -run
+ stream 5 {
+ txreq -req PUT -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxresp
+ expect resp.status == 200
+ } -run
+ stream 7 {
+ txreq -req PATCH -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxresp
+ expect resp.status == 200
+ } -run
+ stream 9 {
+ txreq -req GET -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 11 {
+ txreq -req HEAD -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 13 {
+ txreq -req DELETE -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 15 {
+ txreq -req OPTIONS -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 17 {
+ txreq -req TRACE -url / -scheme http -hdr ":authority" "a" -body "ok"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+} -run
+
#
# Responses
#