From 9b8b237b4b21b1d02e72797f99f19db4617e0139 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sat, 6 Jun 2026 22:20:32 +0300 Subject: [PATCH] add `push` tests Signed-off-by: Mohammed Al Sahaf --- caddytest/spec/http/push/spec.hurl | 115 +++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 caddytest/spec/http/push/spec.hurl diff --git a/caddytest/spec/http/push/spec.hurl b/caddytest/spec/http/push/spec.hurl new file mode 100644 index 000000000..ce0397a34 --- /dev/null +++ b/caddytest/spec/http/push/spec.hurl @@ -0,0 +1,115 @@ +# push initiates HTTP/2 PUSH_PROMISE frames; libcurl does not surface pushed +# streams as headers, so we only validate that push configurations parse and +# do not break the response. + +# Configure Caddy with a single push target +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + root * {{indexed_root}} + push /style.css + file_server +} +``` +HTTP 200 + +# push does not break the response +GET https://localhost:9443/index.html +[Options] +insecure: true +HTTP 200 + + +# Configure Caddy with multiple push targets +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + root * {{indexed_root}} + push /index.txt + push /index.html + respond "Main" +} +``` +HTTP 200 + +# multiple push targets do not break the response +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "Main" + + +# Configure Caddy with conditional push gated by a matcher +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + root * {{indexed_root}} + @html path *.html + push @html /index.txt + file_server +} +``` +HTTP 200 + +# matching path still serves correctly +GET https://localhost:9443/index.html +[Options] +insecure: true +HTTP 200 + +# non-matching path also serves correctly +GET https://localhost:9443/index.txt +[Options] +insecure: true +HTTP 200 + + +# Configure Caddy with push driven by upstream Link header +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + push + header Link "; rel=preload; as=style" + respond "Linked" +} +``` +HTTP 200 + +# bare push parses and forwards the Link header to the client +GET https://localhost:9443/ +[Options] +insecure: true +HTTP 200 +[Asserts] +header "Link" contains "" +body == "Linked"