You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jc...@apache.org on 2017/07/05 19:00:23 UTC

svn commit: r1800913 - in /httpd/test/framework/trunk/t: htdocs/modules/lua/setheaders.lua modules/lua.t

Author: jchampion
Date: Wed Jul  5 19:00:22 2017
New Revision: 1800913

URL: http://svn.apache.org/viewvc?rev=1800913&view=rev
Log:
mod_lua: add some tests for the header table functionality

Added:
    httpd/test/framework/trunk/t/htdocs/modules/lua/setheaders.lua
Modified:
    httpd/test/framework/trunk/t/modules/lua.t

Added: httpd/test/framework/trunk/t/htdocs/modules/lua/setheaders.lua
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/lua/setheaders.lua?rev=1800913&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/modules/lua/setheaders.lua (added)
+++ httpd/test/framework/trunk/t/htdocs/modules/lua/setheaders.lua Wed Jul  5 19:00:22 2017
@@ -0,0 +1,4 @@
+function handle(r)
+    r.headers_out["X-Header"] = "yes"
+    r.headers_out["X-Host"]   = r.headers_in["Host"]
+end

Modified: httpd/test/framework/trunk/t/modules/lua.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/lua.t?rev=1800913&r1=1800912&r2=1800913&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/lua.t (original)
+++ httpd/test/framework/trunk/t/modules/lua.t Wed Jul  5 19:00:22 2017
@@ -10,6 +10,7 @@ my $config = Apache::Test::config();
 my $server = $config->server;
 my $version = $server->{version};
 my $scheme = Apache::Test::vars()->{scheme};
+my $hostport = Apache::TestRequest::hostport();
 
 my $https = "nope";
 $https = "yep" if $scheme eq "https";
@@ -34,21 +35,42 @@ my @ts = (
     { url => "$pfx/method.lua", rcontent => "GET" },
     { url => "$pfx/201.lua", rcontent => "", code => 201 },
     { url => "$pfx/https.lua", rcontent => $https },
+    { url => "$pfx/setheaders.lua", rcontent => "",
+                                    headers => { "X-Header" => "yes",
+                                                 "X-Host"   => $hostport } },
 );
 
-plan tests => 3 * scalar @ts, need 'lua';
+plan tests => 4 * scalar @ts, need 'lua';
 
 for my $t (@ts) {
     my $url = $t->{"url"};
     my $r = GET $url;
     my $code = $t->{"code"} || 200;
+    my $headers = $t->{"headers"};
 
     ok t_cmp($r->code, $code, "code for $url");
     ok t_cmp($r->content, $t->{"rcontent"}, "response content for $url");
+
     if ($t->{"ctype"}) {
         ok t_cmp($r->header("Content-Type"), $t->{"ctype"}, "c-type for $url");
     }
     else {
         skip 1;
+    }
+
+    if ($headers) {
+        my $correct = 1;
+        while (my ($name, $value) = each %{$headers}) {
+            my $actual = $r->header($name) || "<unset>";
+            t_debug "'$name' header value is '$actual' (expected '$value')";
+
+            if ($actual ne $value) {
+                $correct = 0;
+            }
+        }
+        ok $correct;
+    }
+    else {
+        skip 1;
     }
 }