Browse Source

added checks for the line-terminator handling and cleanup the configs

git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@62 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/release-1.3.12
Jan Kneschke 17 years ago
parent
commit
2420fd96d2
  1. 9
      src/mod_fastcgi.c
  2. 9
      tests/Makefile.am
  3. 0
      tests/fastcgi-auth.conf
  4. 15
      tests/fastcgi-responder.conf
  5. 34
      tests/fcgi-responder.c
  6. 50
      tests/run-tests.pl

9
src/mod_fastcgi.c

@ -2025,9 +2025,12 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) {
hlen = 1;
c = hctx->response->ptr + 1;
} else if (NULL != (c = buffer_search_string_len(hctx->response, "\r\n\r\n", 4))) {
hlen = c - hctx->response->ptr + 4;
c += 4;
hlen = c - hctx->response->ptr;
} else if (NULL != (c = buffer_search_string_len(hctx->response, "\n\n", 2))) {
hlen = c - hctx->response->ptr + 2;
c += 2;
hlen = c - hctx->response->ptr;
}
if (c != NULL) {
@ -2053,7 +2056,7 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) {
con->file_started = 1;
if (blen) {
http_chunk_append_mem(srv, con, c + 4, blen + 1);
http_chunk_append_mem(srv, con, c, blen + 1);
joblist_append(srv, con);
#if 0
log_error_write(srv, __FILE__, __LINE__, "sd", "body-len", blen);

9
tests/Makefile.am

@ -2,10 +2,13 @@
testdir=/tmp/lighttpd/
if CHECK_WITH_FASTCGI
check_PROGRAMS=fcgi-auth
check_PROGRAMS=fcgi-auth fcgi-responder
fcgi_auth_SOURCES=fcgi-auth.c
fcgi_auth_LDADD=-lfcgi
fcgi_responder_SOURCES=fcgi-responder.c
fcgi_responder_LDADD=-lfcgi
endif
TESTS=\
@ -14,8 +17,8 @@ run-tests.pl \
cleanup.sh
CONFS=fastcgi-10.conf \
fastcgi-11.conf \
fastcgi-12.conf \
fastcgi-auth.conf \
fastcgi-responder.conf \
fastcgi-13.conf \
bug-06.conf \
bug-12.conf

0
tests/fastcgi-11.conf → tests/fastcgi-auth.conf

15
tests/fastcgi-12.conf → tests/fastcgi-responder.conf

@ -83,20 +83,13 @@ compress.cache-dir = "/tmp/lighttpd/cache/compress/"
compress.filetype = ("text/plain", "text/html")
fastcgi.debug = 0
fastcgi.server = ( "/" => (
fastcgi.server = ( ".fcgi" => (
"grisu" => (
"host" => "192.168.0.2",
"port" => 1027,
"bin-path" => "./fcgi-auth",
"mode" => "authorizer",
"docroot" => "/tmp/lighttpd/servers/www.example.org/pages/",
"port" => 1028,
"bin-path" => "./fcgi-responder",
"check-local" => "disable"
)
# "ulf" => (
# "host" => "192.168.2.41",
# "docroot" => "/home/jan/servers/",
# "port" => 1026
# )
)
)

34
tests/fcgi-responder.c

@ -0,0 +1,34 @@
#include <fcgi_stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main () {
char* p;
while (FCGI_Accept() >= 0) {
if (NULL != (p = getenv("QUERY_STRING"))) {
if (0 == strcmp(p, "lf")) {
printf("Status: 200 OK\n\n");
} else if (0 == strcmp(p, "crlf")) {
printf("Status: 200 OK\r\n\r\n");
} else if (0 == strcmp(p, "slow-lf")) {
printf("Status: 200 OK\n");
fflush(stdout);
printf("\n");
} else if (0 == strcmp(p,"slow-crlf")) {
printf("Status: 200 OK\r\n");
fflush(stdout);
printf("\r\n");
} else {
printf("Status: 200 OK\r\n\r\n");
}
} else {
printf("Status: 500 Internal Foo\r\n\r\n");
}
printf("test123");
}
return 0;
}

50
tests/run-tests.pl

@ -2,7 +2,7 @@
use strict;
use IO::Socket;
use Test::More tests => 120;
use Test::More tests => 124;
my $testname;
@ -32,7 +32,7 @@ sub stop_proc {
close F;
kill('TERM',$pid) or return -1;
select(undef, undef, undef, 0.25);
select(undef, undef, undef, 0.01);
return 0;
}
@ -1137,8 +1137,8 @@ ok(handle_http == 0, 'FastCGI + Host');
ok(stop_proc == 0, "Stopping lighttpd");
$configfile = 'fastcgi-11.conf';
ok(start_proc == 0, "Starting lighttpd with fastcgi-11.conf") or die();
$configfile = 'fastcgi-auth.conf';
ok(start_proc == 0, "Starting lighttpd with $configfile") or die();
@request = ( <<EOF
GET /index.html?ok HTTP/1.0
Host: www.example.org
@ -1147,10 +1147,6 @@ EOF
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'FastCGI - Auth');
ok(stop_proc == 0, "Stopping lighttpd");
$configfile = 'fastcgi-12.conf';
ok(start_proc == 0, "Starting lighttpd with fastcgi-12.conf") or die();
@request = ( <<EOF
GET /index.html?fail HTTP/1.0
Host: www.example.org
@ -1198,4 +1194,42 @@ ok(handle_http == 0, 'Bug #12');
ok(stop_proc == 0, "Stopping lighttpd");
$configfile = 'fastcgi-responder.conf';
ok(start_proc == 0, "Starting lighttpd with $configfile") or die();
@request = ( <<EOF
GET /index.fcgi?lf HTTP/1.0
Host: www.example.org
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } );
ok(handle_http == 0, 'line-ending \n\n');
@request = ( <<EOF
GET /index.fcgi?crlf HTTP/1.0
Host: www.example.org
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } );
ok(handle_http == 0, 'line-ending \r\n\r\n');
@request = ( <<EOF
GET /index.fcgi?slow-lf HTTP/1.0
Host: www.example.org
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } );
ok(handle_http == 0, 'line-ending \n + \n');
@request = ( <<EOF
GET /index.fcgi?slow-crlf HTTP/1.0
Host: www.example.org
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } );
ok(handle_http == 0, 'line-ending \r\n + \r\n');
ok(stop_proc == 0, "Stopping lighttpd");
Loading…
Cancel
Save