diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:01:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:01:31 +0000 |
commit | c9cf025fadfe043f0f2f679e10d1207d8a158bb6 (patch) | |
tree | 3a94effe0bdc0a6814d8134f4ed840d7cc6b6f19 /debian/perl-framework/t/apache/headers.t | |
parent | Adding upstream version 2.4.57. (diff) | |
download | apache2-c9cf025fadfe043f0f2f679e10d1207d8a158bb6.tar.xz apache2-c9cf025fadfe043f0f2f679e10d1207d8a158bb6.zip |
Adding debian version 2.4.57-2.debian/2.4.57-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/perl-framework/t/apache/headers.t')
-rw-r--r-- | debian/perl-framework/t/apache/headers.t | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/debian/perl-framework/t/apache/headers.t b/debian/perl-framework/t/apache/headers.t new file mode 100644 index 0000000..2412eff --- /dev/null +++ b/debian/perl-framework/t/apache/headers.t @@ -0,0 +1,96 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestUtil; +use Apache::TestRequest; + +my %headers; + +my $hasfix = 0; +if (have_min_apache_version("2.4.0")) { + if (have_min_apache_version("2.4.24")) { + $hasfix = 1; + } +} +elsif (have_min_apache_version("2.2.32")) { + $hasfix = 1; +} +if ($hasfix) { + %headers = ( + "Hello:World\r\n" => ["Hello", "World"], + "Hello: World\r\n" => ["Hello", "World"], + "Hello: World \r\n" => ["Hello", "World"], + "Hello: World \t \r\n" => ["Hello", "World"], + "Hello: Foo\r\n Bar\r\n" => ["Hello", "Foo Bar"], + "Hello: Foo\r\n\tBar\r\n" => ["Hello", "Foo Bar"], + "Hello: Foo\r\n Bar\r\n" => ["Hello", "Foo Bar"], + "Hello: Foo \t \r\n Bar\r\n" => ["Hello", "Foo Bar"], + "Hello: Foo\r\n \t Bar\r\n" => ["Hello", "Foo Bar"], + ); +} +else { + %headers = ( + "Hello:World\n" => ["Hello", "World"], + "Hello : World\n" => ["Hello", "World"], + "Hello : World \n" => ["Hello", "World"], + "Hello \t : World \n" => ["Hello", "World"], + "Hello: Foo\n Bar\n" => ["Hello", "Foo Bar"], + "Hello: Foo\n\tBar\n" => ["Hello", "Foo\tBar"], + "Hello: Foo\n Bar\n" => ["Hello", qr/Foo +Bar/], + "Hello: Foo \n Bar\n" => ["Hello", qr/Foo +Bar/], + ); +} + +my $uri = "/modules/cgi/env.pl"; + +plan tests => (scalar keys %headers) * 3, need_cgi; + +foreach my $key (sort keys %headers) { + + print "testing: $key"; + + my $sock = Apache::TestRequest::vhost_socket('default'); + ok $sock; + + Apache::TestRequest::socket_trace($sock); + + $sock->print("GET $uri HTTP/1.0\r\n"); + $sock->print($key); + $sock->print("\r\n"); + + # Read the status line + chomp(my $response = Apache::TestRequest::getline($sock) || ''); + $response =~ s/\s$//; + + ok t_cmp($response, qr{HTTP/1\.. 200 OK}, "response success"); + + my $line; + + do { + chomp($line = Apache::TestRequest::getline($sock) || ''); + $line =~ s/\s$//; + } + while ($line ne ""); + + my $found = 0; + + my ($name, $value) = ($headers{$key}[0], $headers{$key}[1]); + + do { + chomp($line = Apache::TestRequest::getline($sock) || ''); + $line =~ s/\r?\n?$//; + if ($line ne "" && !$found) { + my @part = split(/ = /, $line); + if (@part && $part[0] eq "HTTP_" . uc($name)) { + print "header: [".$part[1]."] vs [".$value."]\n"; + ok t_cmp $part[1], $value, "compare header $name value"; + $found = 1; + } + } + } + while ($line ne ""); + + ok 0 unless $found; +} + |