You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ko...@apache.org on 2016/09/21 10:57:27 UTC

svn commit: r1761716 - in /httpd/test/framework/trunk/t: conf/extra.conf.in modules/brotli.t

Author: kotkov
Date: Wed Sep 21 10:57:27 2016
New Revision: 1761716

URL: http://svn.apache.org/viewvc?rev=1761716&view=rev
Log:
Add a couple of simple tests for mod_brotli.

Added:
    httpd/test/framework/trunk/t/modules/brotli.t   (with props)
Modified:
    httpd/test/framework/trunk/t/conf/extra.conf.in

Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1761716&r1=1761715&r2=1761716&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Wed Sep 21 10:57:27 2016
@@ -979,4 +979,24 @@ LimitRequestFields    32
   </IfVersion>
 </IfDefine>
 
+#
+# mod_brotli test config
+#
+<IfDefine APACHE2>
+  <IfModule mod_alias.c>
+    <IfModule mod_brotli.c>
+        # Reuse existing data for mod_deflate
+        Alias /only_brotli @SERVERROOT@/htdocs/modules/deflate
+        <Location /only_brotli>
+          SetOutputFilter BROTLI_COMPRESS
+        </Location>
 
+        <IfModule mod_deflate.c>
+          Alias /brotli_and_deflate @SERVERROOT@/htdocs/modules/deflate
+          <Location /brotli_and_deflate>
+            SetOutputFilter BROTLI_COMPRESS;DEFLATE
+          </Location>
+        </IfModule>
+    </IfModule>
+  </IfModule>
+</IfDefine>

Added: httpd/test/framework/trunk/t/modules/brotli.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/brotli.t?rev=1761716&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/modules/brotli.t (added)
+++ httpd/test/framework/trunk/t/modules/brotli.t Wed Sep 21 10:57:27 2016
@@ -0,0 +1,67 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+plan tests => 8, 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" => "deflate, 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;
+    }
+} else {
+    skip "skipping tests without mod_deflate" foreach (1..2);
+}

Propchange: httpd/test/framework/trunk/t/modules/brotli.t
------------------------------------------------------------------------------
    svn:eol-style = native