summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/t/apache/pr64339.t
blob: 00097e66f8f20fc0249cd7f53ae235a68fbdf437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use strict;
use warnings FATAL => 'all';

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

my @testcases = (
    # Backend sends Content-Type: application/xml; charset=utf-8
    ['/doc.xml', "application/xml; charset=utf-8", "fóó\n" ],

    # Backend sends Content-Type: application/foo+xml; charset=utf-8
    ['/doc.fooxml', "application/foo+xml; charset=utf-8", "fóó\n" ],

    # Backend sends Content-Type: application/notreallyxml (no charset)
    # This should NOT be transformed or have a charset added.
    ['/doc.notxml', "application/notreallyxml", "f\xf3\xf3\n" ],

    # Sent with charset=ISO-8859-1 - should be transformed to utf-8
    ['/doc.isohtml', "text/html;charset=utf-8", "<html><body><p>fóó\n</p></body></html>" ],
);

# mod_xml2enc on trunk behaves quite differently to the 2.4.x version
# after r1785780, and does NOT transform the response body. Unclear if
# this is a regression, so restricting this test to 2.4.x (for now).

if (have_min_apache_version('2.5.0')) {
    print "1..0 # skip: Test only valid for 2.4.x";
    exit 0;
}

if (not have_min_apache_version('2.4.59')) {
    print "1..0 # skip: Test not valid before 2.4.59";
    exit 0;
}

plan tests => (3*scalar @testcases), need [qw(xml2enc alias proxy_html proxy)];

foreach my $t (@testcases) {
    my $r = GET("/modules/xml2enc/front".$t->[0]);
    
    ok t_cmp($r->code, 200, "fetching ".$t->[0]);
    ok t_cmp($r->header('Content-Type'), $t->[1], "content-type header test for ".$t->[0]);
    ok t_cmp($r->content, $t->[2], "content test for ".$t->[0]);
}