2005-09-01 11:44:57 +00:00
|
|
|
#!/usr/bin/env perl
|
2005-06-26 10:27:41 +00:00
|
|
|
BEGIN {
|
2008-01-15 22:03:59 +00:00
|
|
|
# add current source dir to the include-path
|
|
|
|
# we need this for make distcheck
|
|
|
|
(my $srcdir = $0) =~ s,/[^/]+$,/,;
|
|
|
|
unshift @INC, $srcdir;
|
2005-06-26 10:27:41 +00:00
|
|
|
}
|
2005-05-10 18:48:59 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use IO::Socket;
|
2018-12-11 03:35:21 +00:00
|
|
|
use Test::More tests => 7;
|
2005-06-15 09:37:18 +00:00
|
|
|
use LightyTest;
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
my $tf_real = LightyTest->new();
|
|
|
|
my $tf_proxy = LightyTest->new();
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
my $t;
|
2008-12-07 15:22:42 +00:00
|
|
|
|
2005-05-10 18:48:59 +00:00
|
|
|
## we need two procs
|
|
|
|
## 1. the real webserver
|
|
|
|
## 2. the proxy server
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$tf_real->{PORT} = 2048;
|
|
|
|
$tf_real->{CONFIGFILE} = 'lighttpd.conf';
|
|
|
|
|
|
|
|
$tf_proxy->{PORT} = 2050;
|
|
|
|
$tf_proxy->{CONFIGFILE} = 'proxy.conf';
|
|
|
|
|
2008-12-07 15:22:42 +00:00
|
|
|
ok($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup;
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2008-12-07 15:22:42 +00:00
|
|
|
ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup;
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-08-17 09:52:16 +00:00
|
|
|
GET /index.html HTTP/1.0
|
2005-05-10 18:48:59 +00:00
|
|
|
Host: www.example.org
|
|
|
|
EOF
|
|
|
|
);
|
2005-08-31 12:55:44 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_proxy->handle_http($t) == 0, 'valid request');
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-28 17:25:35 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-08-17 09:52:16 +00:00
|
|
|
GET /index.html HTTP/1.0
|
2005-06-28 17:25:35 +00:00
|
|
|
Host: www.example.org
|
|
|
|
EOF
|
|
|
|
);
|
2005-11-18 13:27:47 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
|
2005-06-28 17:25:35 +00:00
|
|
|
ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
|
|
|
|
|
2008-12-07 15:22:42 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
|
|
|
GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
|
|
|
|
Host: www.example.org
|
|
|
|
EOF
|
|
|
|
);
|
[core] behavior change: stricter URL normalization
behavior change: stricter URL normalization
Prior behavior can be obtained by configuring lighttpd.conf with:
server.http-parseopts = (“url-normalize” => “disable” )
although this is not recommended.
This behavior change was pre-announced with the releases of
lighttpd 1.4.52 (2018.11.28)
lighttpd 1.4.53 (2019.01.27)
The recommended settings are:
server.http-parseopts = (
"header-strict" => "enable",
"host-strict" => "enable",
"host-normalize" => "enable",
"url-normalize" => "enable",
"url-normalize-unreserved" => "enable",
"url-normalize-required" => "enable",
"url-ctrls-reject" => "enable",
"url-path-2f-decode" => "enable",
"url-path-backslash-trans" => "enable",
"url-path-dotseg-remove" => "enable",
"url-query-20-plus" => "enable"
)
The lighttpd defaults with this commit are slightly less strict:
server.http-parseopts = (
"header-strict" => "enable",
"host-strict" => "enable",
"host-normalize" => "enable",
"url-normalize" => "enable",
"url-normalize-unreserved" => "enable",
#"url-normalize-required" => "enable",
"url-ctrls-reject" => "enable",
"url-path-2f-decode" => "enable",
#"url-path-backslash-trans" => "enable",
"url-path-dotseg-remove" => "enable",
#"url-query-20-plus" => "enable"
)
2019-05-04 21:36:31 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3Axxx%20with%20space' } ];
|
2008-12-07 15:22:42 +00:00
|
|
|
ok($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path');
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_real->stop_proc == 0, "Stopping lighttpd");
|
2008-12-07 15:22:42 +00:00
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
2012-11-09 14:23:25 +00:00
|
|
|
$tf_real->stop_proc;
|
|
|
|
$tf_proxy->stop_proc;
|
2008-12-07 15:22:42 +00:00
|
|
|
|
|
|
|
die();
|