httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose Kahan <>
Subject New test: subrequests and content negotiation
Date Fri, 10 Aug 2007 10:44:25 GMT

Here's my first submission. This test is written against your
perl-framework test environment.

It tests that subrequests are correctly parsing and taking into
account directives that are declared in <Directory>, <Location> sections
and .htaccess files. I'm using the same test scenario I gave in bug

Basically, this requires having the following global content-type:
	AddType text/html; charset=iso-8859-1	html/htm

The test consists on overloading the charset to utf-8:
	AddType text/html; charset=utf-8	html/htm

in the test locations under t/apache/subrequests/, one each
for <Directory>, <Location>, and .htaccess. There is a file each
time that is being requested with its complete name 

and through content-negotiation:

It is the content-negotiation that is being processed thru subrequests.

The patch I sent to bug #41960 fixes the subrequest bugs. Without
that patch, one of these tests will return an error (under Apache/2.2.4).

I'm attaching a tgz file which includes a patch to,
and new files to be stored under t/htdocs/apache/subrequests and
t/subrequests.t The tar archive contains the full hierarchy.

I put this test under t/apache rather than under t/modules because it
is testing subrequests, even if we do so thru content-negotiation. The
tests could be expanded to any other directive that is declared for
a specific location.

Comments are welcome.



=== inline version of the test and section follows ==

=== subrequests.t ====

use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

plan tests => 6, have_module qw(mod_negotiation mod_mime);

## Returns ok if the returned content-type is the same as the 
## expected one.
sub check_content_type  
    my $path = shift;
    my $expected = shift;
    my $error_msg = shift;

    my $h = HEAD_STR $path;

    ## parse response headers looking for our headers
    my $actual_value;
    foreach my $head (split /\n/, $h) {
	if ($head =~ /^Content-Type: (.*)$/) {
	    $actual_value = $1;

    ok t_cmp($actual_value, $expected, $error_msg);

## The server is configured to return text/html; charset=iso8859-1 by default
## The different section overrides change this to charset=utf-8. 
## We do the test with and without content-negotiation

my $expected_type = "text/html; charset=utf-8";

check_content_type ("/apache/subrequests/dir_override/hello.html", 
		    "subrequests with <Directory> overrides");
check_content_type ("/apache/subrequests/dir_override/hello", 
		    "subrequests with <Directory> overrides and conn-neg");

check_content_type ("/apache/subrequests/location_override/hello.html",
		    "subrequests with <Location> overrides");
check_content_type ("/apache/subrequests/location_override/hello",
		    "subrequests with <Location> overrides and conn-neg");

check_content_type ("/apache/subrequests/htaccess_override/hello.html",
		    "subrequests with .htaccess overrides");
check_content_type ("/apache/subrequests/htaccess_override/hello",
		    "subrequests with .htaccess overrides and conn-neg");

========== section ==

## subrequests test config

<IfDefine APACHE2>
    <IfModule mod_mime.c>
       AddType text/html;charset=iso-8859-1     html htm

    <IfModule mod_negotiation.c>

       <Directory @SERVERROOT@/htdocs/apache/subrequests/dir_override>
          Options +MultiViews
          AddType text/html;charset=utf-8               html htm

       <Location "/apache/subrequests/location_override">
          Options +MultiViews
          AddType text/html;charset=utf-8               html htm
       <Directory "@SERVERROOT@/htdocs/apache/subrequests/htaccess_override/">
          Options +MultiViews
          AllowOverride FileInfo


View raw message