From afacc3d80b58be77945fbd965b68d407173126a3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 14 Sep 2009 10:13:29 +0200 Subject: tests:webserver: move parsing of request to its own function. (Prepare for really parsing the request...) Michael --- tests/scripts/webserver.pl | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/scripts/webserver.pl b/tests/scripts/webserver.pl index 1dc1646..a006830 100755 --- a/tests/scripts/webserver.pl +++ b/tests/scripts/webserver.pl @@ -75,6 +75,23 @@ sub REAPER { $SIG{CHLD} = \&REAPER; } +sub parse_request($) { + my $client = shift; + + my $request = ""; + while (my $request_line = <$client>) { + $request .= $request_line; + last if ($request_line eq $EOL); + } + + logmsg "request:\n" . + "------------------------------\n" . + "$request" . + "------------------------------"; + + return $request; +} + sub child_action($) { my $client = shift; my $client_ip = shift; @@ -90,16 +107,7 @@ sub child_action($) { $fortune =~ s/\n/$EOL/g; } - my $request = ""; - while (my $request_line = <$client>) { - $request .= $request_line; - last if ($request_line eq $EOL); - } - - logmsg "request:\n" . - "------------------------------\n" . - "$request" . - "------------------------------"; + my $request = parse_request($client); print $client "HTTP/1.0 200 OK$EOL"; print $client "Server: Tinyproxy-Test-Web-Server/$VERSION$EOL"; -- cgit v1.2.3