diff options
author | Jan Kneschke <jan@kneschke.de> | 2005-03-01 13:37:40 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2005-03-01 13:37:40 +0000 |
commit | 2420fd96d25bf938ef6985152f1754e3c75a9f71 (patch) | |
tree | 52611c0e42423b7e04dfd17f39ab9336707a099f | |
parent | bad98d1bba12e9919e5dda5c3f4ad855e942423b (diff) | |
download | lighttpd-git-2420fd96d25bf938ef6985152f1754e3c75a9f71.tar.gz |
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
-rw-r--r-- | src/mod_fastcgi.c | 9 | ||||
-rw-r--r-- | tests/Makefile.am | 9 | ||||
-rw-r--r-- | tests/fastcgi-auth.conf (renamed from tests/fastcgi-11.conf) | 0 | ||||
-rw-r--r-- | tests/fastcgi-responder.conf (renamed from tests/fastcgi-12.conf) | 15 | ||||
-rw-r--r-- | tests/fcgi-responder.c | 34 | ||||
-rwxr-xr-x | tests/run-tests.pl | 50 |
6 files changed, 92 insertions, 25 deletions
diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 48c7f9d6..3e8cace4 100644 --- a/src/mod_fastcgi.c +++ b/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); diff --git a/tests/Makefile.am b/tests/Makefile.am index e9a37771..c3e7e1b9 100644 --- a/tests/Makefile.am +++ b/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 diff --git a/tests/fastcgi-11.conf b/tests/fastcgi-auth.conf index 2b7f73ff..2b7f73ff 100644 --- a/tests/fastcgi-11.conf +++ b/tests/fastcgi-auth.conf diff --git a/tests/fastcgi-12.conf b/tests/fastcgi-responder.conf index 2b7f73ff..3d9be1f6 100644 --- a/tests/fastcgi-12.conf +++ b/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 -# ) ) ) diff --git a/tests/fcgi-responder.c b/tests/fcgi-responder.c new file mode 100644 index 00000000..8237f7c2 --- /dev/null +++ b/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; +} diff --git a/tests/run-tests.pl b/tests/run-tests.pl index 66e58236..df344254 100755 --- a/tests/run-tests.pl +++ b/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"); |