diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 02:04:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 02:04:07 +0000 |
commit | 1221c736f9a90756d47ea6d28320b6b83602dd2a (patch) | |
tree | b453ba7b1393205258c9b098a773b4330984672f /debian/perl-framework/t/modules/brotli.t | |
parent | Adding upstream version 2.4.38. (diff) | |
download | apache2-1221c736f9a90756d47ea6d28320b6b83602dd2a.tar.xz apache2-1221c736f9a90756d47ea6d28320b6b83602dd2a.zip |
Adding debian version 2.4.38-3+deb10u8.debian/2.4.38-3+deb10u8
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/perl-framework/t/modules/brotli.t')
-rw-r--r-- | debian/perl-framework/t/modules/brotli.t | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/debian/perl-framework/t/modules/brotli.t b/debian/perl-framework/t/modules/brotli.t new file mode 100644 index 0000000..fcbed74 --- /dev/null +++ b/debian/perl-framework/t/modules/brotli.t @@ -0,0 +1,78 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestUtil; +use Apache::TestRequest; + +plan tests => 10, need_module 'brotli', need_module 'alias'; + +my $r; + +# GET request against the location with Brotli. +$r = GET("/only_brotli/index.html", "Accept-Encoding" => "br"); +ok t_cmp($r->code, 200); +ok t_cmp($r->header("Content-Encoding"), "br", "response Content-Encoding is OK"); +if (!defined($r->header("Content-Length"))) { + t_debug "Content-Length was expected"; + ok 0; +} +if (!defined($r->header("ETag"))) { + t_debug "ETag field was expected"; + ok 0; +} + +# GET request for a zero-length file. +$r = GET("/only_brotli/zero.txt", "Accept-Encoding" => "br"); +ok t_cmp($r->code, 200); +ok t_cmp($r->header("Content-Encoding"), "br", "response Content-Encoding is OK"); +if (!defined($r->header("Content-Length"))) { + t_debug "Content-Length was expected"; + ok 0; +} +if (!defined($r->header("ETag"))) { + t_debug "ETag field was expected"; + ok 0; +} + +# HEAD request against the location with Brotli. +$r = HEAD("/only_brotli/index.html", "Accept-Encoding" => "br"); +ok t_cmp($r->code, 200); +ok t_cmp($r->header("Content-Encoding"), "br", "response Content-Encoding is OK"); +if (!defined($r->header("Content-Length"))) { + t_debug "Content-Length was expected"; + ok 0; +} +if (!defined($r->header("ETag"))) { + t_debug "ETag field was expected"; + ok 0; +} + +if (have_module('deflate')) { + # GET request against the location with fallback to deflate (test that + # Brotli is chosen due to the order in SetOutputFilter). + $r = GET("/brotli_and_deflate/apache_pb.gif", "Accept-Encoding" => "gzip,br"); + ok t_cmp($r->code, 200); + ok t_cmp($r->header("Content-Encoding"), "br", "response Content-Encoding is OK"); + if (!defined($r->header("Content-Length"))) { + t_debug "Content-Length was expected"; + ok 0; + } + if (!defined($r->header("ETag"))) { + t_debug "ETag field was expected"; + ok 0; + } + $r = GET("/brotli_and_deflate/apache_pb.gif", "Accept-Encoding" => "gzip"); + ok t_cmp($r->code, 200); + ok t_cmp($r->header("Content-Encoding"), "gzip", "response Content-Encoding is OK"); + if (!defined($r->header("Content-Length"))) { + t_debug "Content-Length was expected"; + ok 0; + } + if (!defined($r->header("ETag"))) { + t_debug "ETag field was expected"; + ok 0; + } +} else { + skip "skipping tests without mod_deflate" foreach (1..4); +} |