summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2009-04-01 17:35:17 +0000
committerStefan Bühler <stbuehler@web.de>2009-04-01 17:35:17 +0000
commitce39062dd260960e927be6344a71eca4b0bef314 (patch)
tree716365970dc45a99b04792a985a919504e5e9b6a
parent61332595cb69bd8315f610920fe3879ebc9fe421 (diff)
downloadlighttpd1.4-ce39062dd260960e927be6344a71eca4b0bef314.tar.gz
lighttpd1.4-ce39062dd260960e927be6344a71eca4b0bef314.zip
Fix workaround for incorrect path info/scriptname if fastcgi prefix is "/" (fixes #729)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2421 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--NEWS1
-rw-r--r--src/mod_fastcgi.c10
-rw-r--r--tests/fastcgi-responder.conf12
-rw-r--r--tests/fcgi-responder.c8
-rwxr-xr-xtests/mod-fastcgi.t23
5 files changed, 45 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index c672fe40..d128483f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ NEWS
* Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)
* New lighttpd man page (moved it to section 8) (fixes #1875)
* Create rrd file for empty rrdfile in mod_rrdtool (#1788)
+ * Fix workaround for incorrect path info/scriptname if fastcgi prefix is "/" (fixes #729)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)
diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c
index 3f9a5bd7..45bf14e4 100644
--- a/src/mod_fastcgi.c
+++ b/src/mod_fastcgi.c
@@ -3639,7 +3639,11 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i
*/
/* the rewrite is only done for /prefix/? matches */
- if (extension->key->ptr[0] == '/' &&
+ if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
+ buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
+ con->uri.path->used = 1;
+ con->uri.path->ptr[con->uri.path->used - 1] = '\0';
+ } else if (extension->key->ptr[0] == '/' &&
con->uri.path->used > extension->key->used &&
NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) {
/* rewrite uri.path and pathinfo */
@@ -3648,10 +3652,6 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i
con->uri.path->used -= con->request.pathinfo->used - 1;
con->uri.path->ptr[con->uri.path->used - 1] = '\0';
- } else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
- buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
- con->uri.path->used = 1;
- con->uri.path->ptr[con->uri.path->used - 1] = '\0';
}
}
}
diff --git a/tests/fastcgi-responder.conf b/tests/fastcgi-responder.conf
index 6a782423..c991fbe2 100644
--- a/tests/fastcgi-responder.conf
+++ b/tests/fastcgi-responder.conf
@@ -159,3 +159,15 @@ $HTTP["host"] == "zzz.example.org" {
server.name = "zzz.example.org"
}
+$HTTP["host"] == "wsgi.example.org" {
+ fastcgi.server = (
+ "/" =>
+ ( (
+ "host" => "127.0.0.1", "port" => 10000,
+ "fix-root-scriptname" => "enable",
+ "check-local" => "disable",
+ "bin-path" => env.SRCDIR + "/fcgi-responder",
+ "max-procs" => 1,
+ ) ),
+ )
+}
diff --git a/tests/fcgi-responder.c b/tests/fcgi-responder.c
index 721c2ce2..81f8ca81 100644
--- a/tests/fcgi-responder.c
+++ b/tests/fcgi-responder.c
@@ -40,7 +40,13 @@ int main () {
printf("Status: 500 Internal Foo\r\n\r\n");
}
- printf("test123");
+ if (0 == strcmp(p, "path_info")) {
+ printf("%s", getenv("PATH_INFO"));
+ } else if (0 == strcmp(p, "script_name")) {
+ printf("%s", getenv("SCRIPT_NAME"));
+ } else {
+ printf("test123");
+ }
}
return 0;
diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t
index f0ae0b48..e5057bd9 100755
--- a/tests/mod-fastcgi.t
+++ b/tests/mod-fastcgi.t
@@ -7,7 +7,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 50;
+use Test::More tests => 52;
use LightyTest;
my $tf = LightyTest->new();
@@ -166,7 +166,7 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo/bar' } ];
ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off');
-
+
ok($tf->stop_proc == 0, "Stopping lighttpd");
@@ -282,7 +282,7 @@ EOF
SKIP: {
- skip "no fcgi-responder found", 9 unless -x $tf->{BASEDIR}."/tests/fcgi-responder" || -x $tf->{BASEDIR}."/tests/fcgi-responder.exe";
+ skip "no fcgi-responder found", 11 unless -x $tf->{BASEDIR}."/tests/fcgi-responder" || -x $tf->{BASEDIR}."/tests/fcgi-responder.exe";
$tf->{CONFIGFILE} = 'fastcgi-responder.conf';
ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
@@ -319,6 +319,23 @@ EOF
ok($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
$t->{REQUEST} = ( <<EOF
+GET /abc/def/ghi?path_info HTTP/1.0
+Host: wsgi.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/abc/def/ghi' } ];
+ ok($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
+
+ $t->{REQUEST} = ( <<EOF
+GET /abc/def/ghi?script_name HTTP/1.0
+Host: wsgi.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
+ ok($tf->handle_http($t) == 0, 'SCRIPT_NAME (wsgi)');
+
+
+ $t->{REQUEST} = ( <<EOF
GET /index.fcgi?die-at-end HTTP/1.0
Host: www.example.org
EOF