From a657fbed05535b8f0d5d92eaafcefc727d55f0b1 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Wed, 28 Oct 2026 02:23:04 +0300 Subject: [PATCH] add more `encode` tests Signed-off-by: Mohammed Al Sahaf --- caddytest/spec/http/encode/spec.hurl | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/caddytest/spec/http/encode/spec.hurl b/caddytest/spec/http/encode/spec.hurl index 8a733d2f8..a6540e0ce 100644 --- a/caddytest/spec/http/encode/spec.hurl +++ b/caddytest/spec/http/encode/spec.hurl @@ -20,11 +20,13 @@ localhost { GET https://localhost:9443 Accept-Encoding: gzip [Options] +compressed: true insecure: true HTTP 200 [Asserts] header "Content-Encoding" == "gzip" header "Vary" contains "Accept-Encoding" +body == "This is a test response that should not be compressed with gzip encoding." # encode does not compress when client doesn't accept encoding @@ -137,6 +139,36 @@ header "Content-Encoding" not exists body == "short" +# encode does not use a compression explicitly excluded by the client +# Configure a response that can be compressed with gzip +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + encode gzip { + minimum_length 1 + } + respond "This response can be compressed with gzip." +} +``` + +# encode does not use a compression explicitly excluded by the client +GET https://localhost:9443 +Accept-Encoding: gzip;q=0, identity;q=1 +[Options] +insecure: true +HTTP 200 +[Asserts] +header "Content-Encoding" not exists +body == "This response can be compressed with gzip." + + # Configure Caddy with large response POST http://localhost:2019/load Content-Type: text/caddyfile